Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Seems to me that the problem with storable is that assignment to $_[0] doesn't work as it should work, or more specifically, as it would work in a normal perl subroutine.

For instance when I read this node my first though was "Hmm, you mean

sub STORABLE_thaw { $_[0]= $singleton; }

doesn't work?". And of course when I tried it, it didn't.

Anyway, it seems to me that making assignment to @_ possible in the STORABLE_freeze() hook would resolve your problem, and I think would be backwards compatible.

Ill just add the mandatory shameless plug: with Data::Dump::Streamer this is easy.

package Foo; use Data::Dump::Streamer; my $singleton=bless {},'Foo'; my $proxy=bless [],'Bar'; my $nope; sub DDS_freeze { return if $nope; return ($proxy,"->DDS_thaw") } sub Bar::DDS_thaw { $singleton; } my @array=($singleton,$singleton,$singleton); my $array=Dump(\@array)->Names('array')->Out(); print "$array\n---\n"; eval $array or die $@; $nope=1; Dump($singleton,\@array,$array)->Names(qw(singleton *array array))->Ou +t(); __END__ $array = [ bless( [], 'Bar' )->DDS_thaw(), 'V: $array->[0]', 'V: $array->[0]' ]; $array->[1] = $array->[0]; $array->[2] = $array->[0]; --- $singleton = bless( {}, 'Foo' ); @array = ( $singleton, $singleton, $singleton ); $array = [ $singleton, $singleton, $singleton ];
---
$world=~s/war/peace/g


In reply to Re: Safely altering the behaviour of heavily used modules by demerphq
in thread Safely altering the behaviour of heavily used modules by adamk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-24 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found