perl -E "$str = 'Hi World!'; $sub = \substr $str, 0, 2; $$sub = 'Hello'; say $str; say ref $sub"
Hello World!
LVALUE
####
use feature 'say';
use Data::Dump qw( pp );
use Storable qw/ freeze thaw /;
my $array = [0];
push @$array, \$array->[0];
my $copy = thaw freeze $array;
$array->[0]++;
$copy->[0]++;
say "Array:";
say join ", ", map pp($_), @$array;
say pp $array;
say "\nCopy:";
say join ", ", map pp($_), @$copy;
say pp $copy;
__END__
Array:
1, \1
do {
my $a = [1, 'fix'];
$a->[1] = \$a->[0];
$a;
}
Copy:
1, \1
do {
my $a = [1, 'fix'];
$a->[1] = \$a->[0];
$a;
}
####
my $struct = ["Hi perlmonks"];
push @$struct, \substr($struct->[0], 0, 2);
my $storable = thaw freeze $struct;
my $sereal = decode_sereal encode_sereal $struct;
pp $struct, $storable, $sereal;
${ $_->[1] } = "Hello", say $_->[0] for $struct, $storable, $sereal;
__END__
Can't handle LVALUE data at C:/Programs/Strawberry/perl/vendor/lib/Data/Dump.pm line 374.
(
["Hi perlmonks", '#LVALUE#'],
["Hi perlmonks", \undef],
["Hi perlmonks", \"Hi"],
)
Hello perlmonks
Hi perlmonks
Hi perlmonks