Errin Larsen wrote:
my @numbers; push @numbers, split while <>;
<snip>
why can't I put that variable declaration in the push function? like this:
push my @numbers, split while <>;
The original code could be written as:
my @numbers; while ( <> ) { push @numbers, split; }
Is that really identical to the original code as regards scoping?
If you declare @numbers inside the while loop it will only be seen inside the loop.
use warnings; push my @numbers, split while <>; my @numbers = (1,2,3);
generates the warning: ""my" variable @numbers masks earlier declaration in same scope at ...".
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>