in reply to 2d arrays and 'Can't use string as an ARRAY ref'

another approach, with a few printing examples, also realize that something like $critters[1][2] is valid also.
#!/usr/bin/perl -w use strict; use Data::Dumper; #I made the 2D array bigger as you only had one row my @critters = ( ['a sheep', 'an elephant', 'the wolf'], ['a fish', 'an eel', 'the whale'] ); print "original array\n"; print Dumper \@critters; my @articleList = ('the', 'an', 'a'); my $articleregex = join("|", @articleList); print "one way to access the whale and a sheep\n"; print "$critters[1][2], $critters[0][0]\n"; #the whale a sheep foreach my $rowref (@critters) #each row { foreach my $name (@$rowref) #each "column" in that row { $name =~ s/^($articleregex) //; } } print "\nmodified array:\n"; print Dumper \@critters; print "\nPrint one row\n"; #when derefencing a thing with a subscript, you need to #use {} to make clear what is being dereferenced, i.e. the #entire row print "@{$critters[1]}\n"; my $ref2arow = $critters[1]; #using an reference to a row print "$ref2arow->[1]\n"; #print 2nd column (eel) __END__ original array $VAR1 = [ [ 'a sheep', 'an elephant', 'the wolf' ], [ 'a fish', 'an eel', 'the whale' ] ]; one way to access the whale and a sheep the whale, a sheep modified array: $VAR1 = [ [ 'sheep', 'elephant', 'wolf' ], [ 'fish', 'eel', 'whale' ] ]; Print one row fish eel whale eel
Try adding prints in various places and play with this.