talexb has asked for the wisdom of the Perl Monks concerning the following question:
Interesting behaviour this afternoon. The following code runs OK and prints 'Bar' only.
my $ref; foreach (@$ref) { print "Foo\n"; } print "Bar\n";
But try to assign that non-existent list to another variable and use that ...
my $ref; foreach (my @list = @$ref) { print "Foo\n"; } print "Bar\n";
... and Perl says Use of uninitialized value in array dereference at foo.pl in line 5. Can someone explain why the extra assignment causes an error?
--t. alex
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Uninitialized or not?
by tye (Sage) on Nov 27, 2002 at 18:20 UTC | |
by Aristotle (Chancellor) on Nov 27, 2002 at 19:21 UTC | |
|
Re: Uninitialized or not?
by pg (Canon) on Nov 27, 2002 at 18:19 UTC | |
by talexb (Chancellor) on Nov 27, 2002 at 18:30 UTC | |
|
Re: Uninitialized or not?
by Aristotle (Chancellor) on Nov 27, 2002 at 18:16 UTC | |
|
Re: Uninitialized or not?
by demerphq (Chancellor) on Nov 27, 2002 at 19:37 UTC | |
by tye (Sage) on Nov 27, 2002 at 22:05 UTC | |
by demerphq (Chancellor) on Nov 27, 2002 at 22:18 UTC |