Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Carping in DESTROY.

by eff_i_g (Curate)
on Oct 24, 2006 at 19:10 UTC ( [id://580378]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Carping in DESTROY.
in thread Carping in DESTROY.

Actually, my eval try was in erorr. This is giving me what I want:
sub DESTROY { my $self = shift; eval { store $self, DATA_FILE }; die $@ if $@; }
I partially understand this. This is what Storable is doing:
... sub logcroak { Carp::croak(@_); } ... open(FILE, ">$file") || logcroak "can't create $file: $!"; ...
I'm still a little confused why I have to capture the croak and then die, as opposed to letting it croak.

Replies are listed 'Best First'.
Re^5: Carping in DESTROY.
by Anonymous Monk on Oct 25, 2006 at 10:32 UTC
    croak does something with caller(). DESTROY doesn't have a caller() (that croak recognises). If you do a sub or eval that does provide a caller() that croak recognises and so does the right thing.
      Ah ha! Thank you very much!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-19 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found