X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlintro.pod;h=9973fd62c1b3120c8134766ab2707e105cf17be7;hb=8d159ec130d0a3a6340d8398c9db207a5efafc87;hp=5e5923d8b6e3cb547081363d4c395556e1ea185f;hpb=41489bc0abf2c83d62c1f6f1bd6266aad0082022;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlintro.pod b/pod/perlintro.pod index 5e5923d..9973fd6 100644 --- a/pod/perlintro.pod +++ b/pod/perlintro.pod @@ -54,22 +54,28 @@ Alternatively, put this as the first line of your script: ... and run the script as C. Of course, it'll need to be executable first, so C (under Unix). +(This start line assumes you have the B program. You can also put +directly the path to your perl executable, like in C<#!/usr/bin/perl>). + For more information, including instructions for other platforms such as Windows and Mac OS, read L. =head2 Safety net -Perl by default is very forgiving. In order to make it more roboust -it is recommened to start every program with the following lines: +Perl by default is very forgiving. In order to make it more robust +it is recommended to start every program with the following lines: #!/usr/bin/perl use strict; use warnings; -The C line imposes some restrictions that will mainly stop -you from introducing bugs in your code. The C is more or -less equivalent to the command line switch B<-w> (see L). This will -catch various problems in your code and give warnings. +The two additional lines request from perl to catch various common +problems in your code. They check different things so you need both. A +potential problem caught by C will cause your code to stop +immediately when it is encountered, while C will merely +give a warning (like the command-line switch B<-w>) and let your code run. +To read more about them check their respective manual pages at L +and L. =head2 Basic syntax overview @@ -296,7 +302,7 @@ are defined. Using C in combination with a C at the top of your Perl scripts means that the interpreter will pick up certain common programming errors. For instance, in the example above, the final -C would cause a compile-time error and prevent you from +C would cause a compile-time error and prevent you from running the program. Using C is highly recommended. =head2 Conditional and looping constructs @@ -363,7 +369,7 @@ You can also use C in a post-condition: Exactly like C: - for ($i=0; $i <= $max; $i++) { + for ($i = 0; $i <= $max; $i++) { ... } @@ -376,7 +382,7 @@ the more friendly list scanning C loop. print "This element is $_\n"; } - print $list[$_] foreach 1 .. $max; + print $list[$_] foreach 0 .. $max; # you don't have to use the default $_ either... foreach my $key (keys %hash) { @@ -531,7 +537,7 @@ expressions. These are documented at great length in L, but for the meantime, here's a quick cheat sheet: . a single character - \s a whitespace character (space, tab, newline) + \s a whitespace character (space, tab, newline, ...) \S non-whitespace character \d a digit (0-9) \D a non-digit @@ -653,7 +659,7 @@ to database integration to graphics. A categorized list of modules is also available from CPAN. To learn how to install modules you download from CPAN, read -L +L. To learn how to use a particular module, use C>. Typically you will want to C>, which will then give