I had a similar experience with Storable. Is there a big problem with simply cloning bar: %$ref = %$bar?
Alternatively, what about making $ref into a proxy for $bar:
{
package Proxy;
our $AUTOLOAD;
sub AUTOLOAD
{
my $self = shift;
my $name = $AUTOLOAD;
$name =~ s/.*://;
return if $name eq 'DESTROY';
$self->{bar}->$name(@_);
}
sub isa { (shift)->{bar}->isa(@_) }
sub can { (shift)->{bar}->can(@_) }
}
sub some_sub {
my $ref = shift;
%$ref = (bar => $bar);
bless $ref, "Proxy";
}
This code is untested, but I've had success with similar techniques. It assumes that $ref is a hash reference-type object, and that you never access the contents of the hash directly.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.