in reply to Re: Simple question about foreach and my.
in thread Simple question about foreach and my.
> perl -lwe '$x=$y=0; foreach $x (0..9) { ++$y } print "$x, $y"' 0, 10 > perl -lwe 'my($x,$y)=(0,0); foreach $x (0..9) { ++$y } print "$x, $y +"' 0, 10 > perl -lwe '$y=0; foreach $x (0..9) { ++$y } print ! defined $x,", $y +"' 1, 10 > perl -lwe 'my $y=0; foreach my $x (0..9) { ++$y } print ! defined $x +,", $y"' Name "main::x" used only once: possible typo at -e line 1. 1, 10 >
|
|---|