in reply to array reference

Hi cammac,

Why not just try it? ...

use strict; use warnings; use Data::Dumper; my $parray = [ qw( a b c ) ]; printf "Array before change is: %s\n", Dumper($parray); my $phash = { 'array' => $parray, }; printf "Hash before change is: %s\n", Dumper($phash); push @$parray, 'd', 'e', 'f'; printf "Array after change is: %s\n", Dumper($parray); printf "Hash after change is: %s\n", Dumper($phash);

The results indicate that you do NOT need to do anything manually:

Array before change is: $VAR1 = [ 'a', 'b', 'c' ]; Hash before change is: $VAR1 = { 'array' => [ 'a', 'b', 'c' ] }; Array after change is: $VAR1 = [ 'a', 'b', 'c', 'd', 'e', 'f' ]; Hash after change is: $VAR1 = { 'array' => [ 'a', 'b', 'c', 'd', 'e', 'f' ] };

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: array reference
by ikegami (Patriarch) on Aug 22, 2007 at 15:29 UTC

    Not everything can be answered by "try it and see". This is one of those cases where TIAS doesn't work. More importantly, someone asking that question surely knows that (since realloc can return the same pointer it was passed).

    You'll also get a false positive if Perl preallocates more space than it needs (and it does) and the array size is grown insufficiently.

    Your test didn't proove anything.