develooper Front page | perl.perl5.porters | Postings from May 2013

[perl #118139] Storable in DESTROY blocks

Thread Previous | Thread Next
From:
Reini Urban via RT
Date:
May 23, 2013 16:06
Subject:
[perl #118139] Storable in DESTROY blocks
Message ID:
rt-3.6.HEAD-2650-1369325159-116.118139-15-0@perl.org
On Thu May 23 08:36:26 2013, rurban wrote:
> The attached patch fixes the DESTROY issue. 
> This is a pretty rare use case, but deserves a CPAN release also.
> 
> use Storable;
> BEGIN { store {}, "foo"; }
> package foo;
> sub new { return bless {} }
> DESTROY { open $fh, "<", "foo";
>   eval { Storable::pretrieve($fh); }; #SEGV
>   unlink "foo";
> }
> package main;
> foo->new();

I"m not sure how to document the easy fix for the user 
in this use-case:
Call the objects DESTROY method before global destruction.

E.g. by setting foo->new() to a lexical, 
  my $x = foo->new();
or by using it in a block, 
and it will be destroyed when going out of scope.

-- 
Reini Urban

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=118139

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About