in reply to Re: push with interpolated variable
in thread push with interpolated variable

push (@array, $value);
is the same as
push @array, "$value";
It's not.
#!/usr/bin/perl use strict; use warnings; my (@array, $value); @array = ("foo"); $value = []; push(@array, $value); $array[-1][0] = "bar"; print $array[-1][0], "\n"; @array = ("foo"); $value = []; push @array, "$value"; $array[-1][0] = "bar"; print $array[-1][0], "\n"; __END__ bar Can't use string ("ARRAY(0x818427c)") as an ARRAY ref while "strict re +fs" in use

Replies are listed 'Best First'.
Re^3: push with interpolated variable
by holli (Abbot) on Jan 20, 2005 at 12:13 UTC
    Indeed. I assumed $value contains a simple scalar (a string or a number). If $value contains a reference then "$value" is stringified.

    Thanks for the clarification, i never thought about that.

    holli, regexed monk