Perl101

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Event

    Perl101 - Presentation Transcript

    1. Corso introduttivo a Perl Pisa, 22 Ottobre 2009
    2. Corso introduttivo a Perl Stefano Rodighiero http://www.stefanorodighiero.net stefano.rodighiero@gmail.com Twitter: @larsen
    3. Cosa potete aspettarvi da questo corso Sapere scrivere dei semplici programmi Perl Sapere leggere programmi Perl Sapere dove trovare altra documentazione
    4. Corso introduttivo a Perl •Variabili •Riferimenti e strutture dati •Subroutine •I/O •Espressioni regolari •Moduli •CPAN
    5. Perl ~1987, Larry Wall
    6. Perl 4.0 1991, Camel Book
    7. Perl 5 1994, Perl come lo conosciamo ora
    8. Perl 5.10
    9. Perl 5.11
    10. Perl 5.11 5.11.1 l'altro ieri!
    11. Perl 6 ???
    12. Rakudo
    13. Rakudo * ~ Primavera 2010
    14. Perl
    15. PERL Practical Extraction and Report Language Pathologically Eclectic Rubbish Lister Polymorphic Existential Recursive Lambdas
    16. perl
    17. Perl TIMTOWTDI Rendere facili le cose facili, possibili le cose difficili Simile ad un linguaggio naturale
    18. Procurarsi Perl Se usate un sistema *NIX, molto probabilmente lo avete già Per Windows, ActiveState Perl oppure Strawberry Perl
    19. Come cercare aiuto
    20. perldoc
    21. mongers@perl.it
    22. #perl.it
    23. www.perlmonks.org
    24. Variabili ::
    25. $
    26. Scalari Un valore singolo Numeri e stringhe di caratteri
    27.  Esercizi http://www.stefanorodighiero.net/perl101/examples.tgz
    28. @
    29. Array Un insieme ordinato di valori scalari
    30.  Esercizi http://www.stefanorodighiero.net/perl101/examples.tgz
    31. %
    32. Hash Un insieme (non ordinato) di coppie chiave-valore scalare Fondamentale!
    33.  Esercizi http://www.stefanorodighiero.net/perl101/examples.tgz
    34. Riferimenti e strutture dati ::
    35. Riferimenti e strutture dati :: Una questione in sospeso...
    36. Riferimenti e strutture dati :: Una questione in sospeso...
    37. use feature 'say'; # E` esattamente equivalente a questo my @array = (1, 2, 3, 4, 5, 6); say $array[1]; # Come si fa allora un array di array? # Lo vediamo piu` tardi...
    38. Uno scalare può contenere:
    39. Un numero.
    40. Una stringa.
    41. Un riferimento ad un'altra variabile.
    42. my @array = (1, 2, 3, 4, 5, 6);
    43. my @array = ((1, 2, 3), (4, 5, 6));
    44. my @array = ((1, 2, 3), (4, 5, 6)); @array 1 2 3 4 5 6
    45. my @array = ((1, 2, 3), (4, 5, 6)); @array 1 • 2 3 4 5 6
    46. my @array = ((1, 2, 3), (4, 5, 6)); @array 1 • 2 3 • 4 5 6
    47. my @array = ([1, 2, 3], [4, 5, 6]); @array 1 • 2 3 • 4 5 6
    48.  Esercizi http://www.stefanorodighiero.net/perl101/examples.tgz
    49. Subroutine ::
    50. Subroutine :: Codice riusabile (Don't repeat yourself: DRY) Strumento di astrazione Configurabilità del comportamento
    51.  Esercizi http://www.stefanorodighiero.net/perl101/examples.tgz
    52. Controllo del flusso ::
    53. Esecuzione condizionale ::
    54. if ... elsif ... else
    55. if (EXPR) BLOCK
    56. ne, if (EXPR) BLOCK ssio e spre tata Un' valu e v iene ch sto nte i n co ole ano. bo
    57. ne, ssio Falso Un' e spre e v iene valu tata ch sto 0 (il numero zero) nte i n co ano. '' (la stringa vuota) '0' (una stringa che contiene il singolo ole bo carattere corrispondente alla cifra zero) undef
    58. ne, ssio Vero Un' e spre e v iene valu tata ch sto Tutto il resto nte i n co ole ano. bo
    59. ne, if (EXPR) BLOCK ssio e spre tata Un' valu e v iene ch sto nte i n co ole ano. bo Un in sieme istru di zioni, da gr delim affe. itate
    60. if (EXPR) BLOCK
    61. if (EXPR) BLOCK else BLOCK
    62. if (EXPR) BLOCK elsif (EXPR) BLOCK else BLOCK
    63. if (EXPR) BLOCK elsif (EXPR) BLOCK else BLOCK
    64. given ... when
    65. Come switch e case in altri linguaggi
    66. given (EXPR) { when (EXPR) BLOCK ... default BLOCK }
    67. given (EXPR) { when (EXPR) BLOCK ... default BLOCK }
    68. given (EXPR) { when (EXPR) BLOCK ... default BLOCK }
    69. given (EXPR) { when (EXPR) BLOCK ... default BLOCK }
    70. Modificatori di statement ::
    71. ... if EXPR; ... unless EXPR; ... while EXPR; ... until EXPR; ... foreach EXPR;
    72. Iterazione ::
    73. for / foreach
    74. foreach (LIST) BLOCK
    75. foreach (LIST) BLOCK
    76. lori ei va lis ta d lare foreach (LIST) La i cic ual s ui q BLOCK
    77. lori ei va lis ta d lare foreach (LIST) La i cic ual s ui q BLOCK Un in sieme istru di zioni, da gr delim affe. itate
    78. lori ei va lis ta d lare foreach (LIST) La i cic ual s ui q BLOCK Un in sieme istru di All'in zioni, terno da gr delim blocc del affe. itate o, il eleme singo nto è lo $_
    79. foreach my $var (LIST) BLOCK
    80. All'interno del blocco è tipico usare ulteriori istruzioni per il controllo di flusso
    81. next
    82. redo
    83. last
    84. while
    85. while (EXPR) BLOCK
    86. one spr essi L 'e tat a in while (EXPR) valu viene BLOCK sto c onte ano b oole
    87. one spr essi L 'e tat a in while (EXPR) valu viene BLOCK sto c onte ano b oole Il bl occo esegu viene ito f condi inchè zione la è vera
    88.  Esercizi http://www.stefanorodighiero.net/perl101/examples.tgz
    89. I/O ::
    90. Lettura da file
    91. open my $fh, "<", $filename;
    92. open my $fh, "<", $filename; Il fil eh an dle
    93. open my $fh, "<", $filename; Il In fil eh ap ch an rir em dle ei od lf ali ile tà ?
    94. open my $fh, "<", $filename; Il e fil fil In eh ap ch del an rir em dle ei od me lf ali ile tà no ? Il
    95. Modalità di apertura
    96. < Lettura > Scrittura >> Append +< Read/write Write/read (se il file esiste lo +> tronca
    97. my $line = <$fh>;
    98. my $line = <>; ata, a ab brevi Form ST DIN leg ge da
    99. my $line = <DATA>; pec iale, For ma s dal legge ATA le D file hand
    100. close $fh;
    101.  Esercizi http://www.stefanorodighiero.net/perl101/examples.tgz
    102. Espressioni regolari ::
    103. Un linguaggio dentro il linguaggio.
    104. Espressioni regolari Una maniera per esprimere insiemi di stringhe di caratteri Riconoscimento di formati Manipolazione del testo
    105. /foo/
    106. foo
    107. foo bar foo baz
    108. foo foo baz bar
    109. foo foo baz bar
    110. bar foo baz foo
    111. bar foo baz foo
    112. bar foo baz foo
    113.  Esercizi http://www.stefanorodighiero.net/perl101/examples.tgz
    114. Moduli ::
    115. Insieme alle subroutine, ulteriore strumento di astrazione
    116.  Esercizi
    117. Ulteriori cenni su strict
    118. Quando strict si lamenta per le variabili?
    119. 1.
    120. La variabile non è completamente qualificata.
    121. 2.
    122. Non è una variabile lessicale precedentemente definita.
    123. 3.
    124. Non è una variabile package precedentemente definita con vars
    125. CPAN ::
    126. search.cpan.org
    127. $ perl -MCPAN -e shell
    128. $ cpan
    129. Qualche modulo utile
    130. DBI
    131. CGI
    132. Template
    133. Getopt::Long
    134. DateTime
    135. Regexp::Common
    136. HTML::Parser::*
    137. XML::LibXML
    138. Moose
    139. Bibliografia ::
    140. Bibliografia :: Programming Perl Larry Wall et al. Oreilly, 1995
    141. Bibliografia :: Pocket Perl Stefano Rodighiero Apogeo, 2008
    SlideShare Zeitgeist 2009

    + Stefano RodighieroStefano Rodighiero Nominate

    custom

    128 views, 0 favs, 1 embeds more stats

    http://www.stefanorodighiero.net/perl101
    Corso int more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 128
      • 115 on SlideShare
      • 13 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 4
    Most viewed embeds
    • 13 views on http://www.stefanorodighiero.net

    more

    All embeds
    • 13 views on http://www.stefanorodighiero.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events