#! /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'); # Remove articles from animals OUTER: foreach my $animal ($twoDimArray[0]) { INNER: foreach my $article (@articleList) { if (index ($animal, $article) == 0) { # Article found at beginning of $animal. Remove it. $animal = substr($animal, (length($article) + 1)); # Only need to remove one article from each animal last INNER; } } } # Print a list of three animals # I expect to see the output # Animal: sheep # Animal: elephant # Animal: wolf # Why do I get only get one animal, and an array reference? # Animal: ARRAY(0x8343218) foreach my $animal ($twoDimArray[0]) { print "Animal: $animal\n"; }