sub new {
...
my %self = %{$_[0]} if ref $_[0];
...
}
####
use strict;
use warnings;
my $a = testref1();
my $b = testref1();
$b->{test}="";
$a->{test}="hello world";
print $b->{test} . "\n\n";
my $c = testref2();
my $d = testref2();
$d->{test}="";
$c->{test}="hello world";
print $d->{test} . "\n\n";
sub testref1{
my %x = %{$_[0]} if ref $_[0];
print "testref1:" . \%x . "\n";
return(\%x);
}
sub testref2{
my %x;
%x = %{$_[0]} if ref $_[0];
print "testref2:" . \%x . "\n";
return(\%x);
}
####
testref1:HASH(0x9f952c4)
testref1:HASH(0x9f952c4)
hello world
testref2:HASH(0x9f95864)
testref2:HASH(0x9f7b7a4)