Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: How do I make the garbage collector throw an exception when it fails to auto-close a filehandle?

by Aristotle (Chancellor)
on Jan 13, 2007 at 07:37 UTC ( #594506=note: print w/ replies, xml ) Need Help??


in reply to Re: How do I make the garbage collector throw an exception when it fails to auto-close a filehandle?
in thread How do I make the garbage collector throw an exception when it fails to auto-close a filehandle?

Yah, Iím aware of the concept. I would use it (more readily than a special IO class, possibly, although my opinion on that changes every other day), but for a single close $fh or die "Couldn't close: $!" statement it just doesnít seem worthwhile. Itís maddening Ė itís a simple single statement whose absence is not worth complicating the code for, but itís still annoying to have to write it, and thereís so little missing to make it unnecessaryÖ

Makeshifts last the longest.


Comment on Re^2: How do I make the garbage collector throw an exception when it fails to auto-close a filehandle?
Re^3: How do I make the garbage collector throw an exception when it fails to auto-close a filehandle?
by ikegami (Pope) on Jan 14, 2007 at 06:37 UTC

    Nevermind. die in destrutor. Doesn't work.

    use strict; use warnings; use ReleaseAction qw( on_release ); $| = 1; sub something { my $closer = on_release { print "on_release enter\n"; die("test"); print "on_release exit\n"; }; } print "pre\n"; something(); print "post\n";

    outputs

    pre on_release enter (in cleanup) test at script.pl line 11. post

    Tested on 5.6.1 & 5.8.8

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://594506]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2014-09-20 17:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls