On Aug 23, 2012, at 12:57 PM, Chris Stinemetz wrote: > Hello List, > I'm trying to grep an array of arrays, but I am getting the following error: > > Can't use string ("1") as an ARRAY ref while "strict refs" in use at > form.pl line 121, <$COORDS> line 1281. > Press any key to continue . . . > > > > Below is the grep statement: > > print grep { $_->[0][0] >= 0 } @coords; > Any idea what I am doing wrong?
If @coords is an array of arrays, then $coords[0] is a reference to an array, and $coords[0][0] is the first element of that array (I bet that is equal to 1). In 'grep { $_->[0][0] } @coords;', $_ is set equal to each element of the @coords array, beginning with $coords[0]. Since that value is a reference to an array, $_->[0] will be the first element of that array. That is what you want to compare to 0, not $_->[0][0]. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/