in reply to Simple question about foreach and my.
If the my was inside the foreach, $element would not have scope outside the loop, and therefore you'd run into problems with the print statement.my $element; foreach $element (@set_of_numbers) { last if $element < $critical_value; } print "$element is below the critical value.\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Simple question about foreach and my.
by petral (Curate) on Mar 27, 2001 at 23:39 UTC |