Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
$o is being carried through to each foreach loop but is not available outside. I don't get it. Ideas?use strict; use warnings; my @outer = (qw| one two three |); print "First\n"; foreach my $o (@outer) { print $o, "\n"; } print "Second\n"; foreach my $o (@outer) { $o .= 'loop'; print $o, "\n"; } #print $o, "\n"; # Comment out compile time error print "Third\n"; foreach my $o (@outer) { print $o, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: foreach my $var scope oddness
by ikegami (Patriarch) on May 21, 2006 at 00:40 UTC | |
by GrandFather (Saint) on May 21, 2006 at 07:14 UTC | |
|
Re: foreach my $var scope oddness
by merlyn (Sage) on May 20, 2006 at 23:59 UTC | |
|
Re: foreach my $var scope oddness
by Zaxo (Archbishop) on May 21, 2006 at 00:12 UTC | |
|
Re: foreach my $var scope oddness
by jesuashok (Curate) on May 21, 2006 at 05:12 UTC |