Witness the following:
$ perl -Mstrict -Mdiagnostics -E 'my $a = "3"; say $a->[0];' Can't use string ("3") as an ARRAY ref while "strict refs" in use at - +e line 1 (#1) (F) You've told Perl to dereference a string, something which use strict blocks to prevent it happening accidentally. See "Symbolic references" in perlref. This can be triggered by an @ o +r $ in a double-quoted string immediately before interpolating a varia +ble, for example in "user @$twitter_id", which says to treat the conten +ts of $twitter_id as an array reference; use a \ to have a literal @ symbol followed by the contents of $twitter_id: "user \@$twitter_i +d". Uncaught exception from user code: Can't use string ("3") as an ARRAY ref while "strict refs" in use +at -e line 1.
If you are getting this message, then your code is doing what my code demonstrates. It may take a more complex path to get there, but the result it the same; some variable that you think has an array reference in it actually has the string "3", and you are attempting to dereference it.
Dave
In reply to Re^3: Adding an element to an array
by davido
in thread Adding an element to an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |