On Jun 19, Bob Mangold said:
>I may have a bug somewhere in my code, but I can't find it. Before I
>look again though please answer this for me.
>my ($line) = "hello";
>foreach $line (<>){
> ..... whatever
>}
>print $line;
>
>Should it print the last line in <> or 'hello'?
I don't think the other responders tested their code. If they had, they'd
see that $line would retain its value.
my $line = 1;
for $line (1 .. 10) { ; }
print $line; # 1
This is because the looping variable is implicitly localized to the loop
itself. This is not a bug.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **