Do you know where your variables are? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Inside a foreach loop (for is synonymous with foreach) the $_ variable is aliased to each element of the list over which you are iterating. Sometimes it's called the "topic" variable, because it is the topic of each loop iteration unless you explicitly specify another variable. The code you demonstrated is equivalent to this:
...which is about the same as...
...which can be unrolled as...
A foreach loop that contains a simple statement in its block can be inverted to $hash{$_} = $new foreach $a, $b;, and further shortened with for. This should be discussed in greater (and possibly more accurate) detail in perlsyn. Dave In reply to Re^3: Perl Syntax
by davido
|
|