- or download this
#!/usr/bin/perl -w
...
foreach (@array) {
printf "%s\n", $_;
}
- or download this
# Code sample 2 -- Come to think of it, I want the indices too ...
...
my $item = $array[$i];
printf "%3d. $item\n", $i + 1;
}
- or download this
# Code sample 3 -- minor changes from the original "foreach"
# loop (Code sample 1)
...
foreach (@array) {
printf "%3d. %s\n", $loopcount + 1, $_;
}
- or download this
$# The output format for printed numbers. This variable
is a half-hearted attempt to emulate awk's OFMT variable.
...
number sign.)
Use of $# is deprecated.