in reply to my $x = <expr>; vs my $x; $x = <expr>;
Which, due a bug in Perl, causes $x not to be cleared at the end of the block, and so to still have its old value on the next entry to the block, egmy $x = expresssion if condition
which outputs:for (1..3) { my $x = "foo\n" if $_ > 9999; print $x; $x = "bar\n"; }
Use of uninitialized value in print at /tmp/p line 5. bar bar
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: my $x = <expr>; vs my $x; $x = <expr>;
by Aristotle (Chancellor) on Jun 05, 2004 at 21:31 UTC | |
by dave_the_m (Monsignor) on Jun 05, 2004 at 21:41 UTC | |
by halley (Prior) on Jun 07, 2004 at 15:20 UTC |