in reply to "my $filehandle" scoping strange problem
B::Deparse is your friend in strange syntax corners.
$ perl -MO=Deparse,-p,-q # . . . your first example here ^D unless (open(my $fh, '<f1.txt')) { do { print(STDERR "can't open <f1.txt, but nevermind, I'll try f2.t +xt\n"); (open($fh, '<f2.txt') or die(q[still can't...])); }; } print(<$fh>);
So you can see now that $fh is scoped to the unless block that's been implicitly created.
Update: Not that that's not a little wierd, mind you. After looking at it a second time it's slightly surprising.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: "my $filehandle" scoping strange problem
by vkon (Curate) on Apr 14, 2006 at 12:56 UTC | |
by Fletch (Bishop) on Apr 14, 2006 at 13:30 UTC | |
by vkon (Curate) on Apr 14, 2006 at 13:54 UTC |