#! /usr/bin/perl -w use strict; use warnings; # Create a one-dimensional array my @row = ('a sheep', 'an elephant', 'the wolf'); # Use it as the first row in a 2-dimensional array my @twoDimArray = (\@row); # List of articles in the English language my @articleList = ('the', 'a', 'an'); # This code block produces the error # "Can't use string ("RAY(0x8641210)") as an ARRAY ref while "strict refs" in use at ./arraytest.pl line 22." # # Remove articles from animals OUTER: for (my $count = 0; $count < 3;$count++) { INNER: foreach my $article (@articleList) { if (index ($twoDimArray[0][$count], $article) == 0) { # Article found at beginning of $animal. Remove it. $twoDimArray[0] = substr($twoDimArray[0], (length($article) + 1)); # Only need to remove one article from each animal last INNER; } } } # Print a list of animals foreach my $animal ($twoDimArray[0]) { print "Animal: $animal\n"; }