Linguistics 408/508 |
Fall 2003 |
Hammond |
if
.while
.for
. A last point: incrementing and decrementing are so
common that there is a common abbreviation for it: $a++
is the
same as $a = $a + 1
and $a--
is the same as
$a = $a - 1
.foreach
. The foreach
structure is quite
useful; it allows you to iterate over some list. Here's how it looks:
foreach $variable (list of items) { list of statements }
The list of items can either be a comma-separated list (example) or an array (example).
Numbers and letters are used in list context so often that there is a special abbreviation that you can use for them, e.g.("a".."e")
is the
same thing as ("a", "b", "c", "d", "e")
.perl
followed by the name of the program at the DOS
prompt. Anything that follows the name of the program is automatically put in
the special array variable @ARGV
. This can then be referred to
in programs (example).