$c's value becomes the last element of the list (90). But if you do this:my $c = qw / 4 6 8 90/;
$c is now 4, the number of elements of the array (I think this would also trigger a warning that @_ may be overwritten). But if you do this:$c = split / /, "the quick brown fox";
now this behaves as an anonymous array et $c is assigned to "brown" (and there no longer any warning, because Perl sort of built an anonymous array). And if you do this:$c = (split / /, "the quick brown fox")[2];
$c's value is now something like "ARRAY(0x80359d10)", i.e. an array reference. and you need something like this:$c = [split / /, "the quick brown fox"];
to print the third element of the array. This is really an array ref, not an array.print $c->[2];
In reply to Re^6: Problem with traversing a two dimensional array (to create an arrayref use [ ] )
by Laurent_R
in thread Problem with traversing a two dimensional array
by SiNoEvol
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |