I have the code:
push @$args{"ARRAY"}, "value";
This gives warning saying:
push on reference is experimental at ...
If I just use block around the array:
push @{args{"ARRAY"}}, "value";
Then the warning disappears. Why is this happening?
@$args{"ARRAY"}
is equivalent to @{$args}{"ARRAY"}
, not @{$args{"ARRAY"}}
. From perlref
, section "Using References":
Because of being able to omit the curlies for the simple case of
$$x
, people often make the mistake of viewing the dereferencing symbols as proper operators, and wonder about their precedence. If they were, though, you could use parentheses instead of braces. That's not the case. Consider the difference below; case 0 is a short-hand version of case 1, not case 2:$$hashref{"KEY"} = "VALUE"; # CASE 0 ${$hashref}{"KEY"} = "VALUE"; # CASE 1 ${$hashref{"KEY"}} = "VALUE"; # CASE 2 ${$hashref->{"KEY"}} = "VALUE"; # CASE 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With