in reply to Catching errors in closing lexical filehandles
I have no idea why eval drops this instead of converting to $@, but you can check $! after a block exit.
It would be wise to clear $! beforehand so you don't see leftovers.$ perl -e'eval{open my $fh, ">", "/dev/full"; print $fh "Foo\n";}; pri +nt $!' No space left on device
use Fatal qw/open close/; { $! = undef; open my $fh, '>', '/dev/full'; print $fh 'short text' or die $!; } die $! if $!;
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: You *Can* Catch errors in closing lexical filehandles
by merlyn (Sage) on Sep 27, 2004 at 17:52 UTC | |
by ihb (Deacon) on Sep 27, 2004 at 18:17 UTC | |
by merlyn (Sage) on Sep 27, 2004 at 18:37 UTC | |
by ihb (Deacon) on Sep 27, 2004 at 23:09 UTC | |
by Zaxo (Archbishop) on Sep 27, 2004 at 22:53 UTC | |
|
Re: You *Can* Catch errors in closing lexical filehandles
by Anonymous Monk on Sep 27, 2004 at 15:53 UTC |