On 10-12-03 11:40 AM, Odin Liu wrote:
I consider $_ is a value-copy of the loop-element, but as shown in a
while loop inside a for loop, it seems that $_ is a reference of the
loop-element.
The loop variable for a foreach loop is the actual element of the array.
Consider:
#!/usr/bin/perl
use strict;
use warnings;
my @outer = qw( a b c );
my @inner = ( 1, 2, 3 );
foreach ( @outer ){
print "$_\n";
foreach ( @inner ){
$_ .= ' (more)';
print "\t$_\n";
}
}
__END__
Notice that @inner is modified every time through the loop.
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
The secret to great software: Fail early & often.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/