Please send questions to
st10@humboldt.edu .
#!/usr/bin/perl
#----------------------------------------------------------
# can arrays contain arrays in Perl?
# can hashes contain hashes?
# can a hash contain arrays?
# can an array contain hashes?
# etc.!
#
# FROM: http://tihlde.org/~pergh//perlfaq/5.2.html
# last modified: 4-14-03
#----------------------------------------------------------
@two_d = ( ["hi", "hello", "bonjour"], ["bye", "bye now",
"arrivaderci", "au revoir"] );
print "largest array index of \@two_d: $#two_d\n";
print "\@two_d[0]: @two_d[0]\n";
print "\$two_d[0][0]: $two_d[0][0]\n";
print "@two_d\n";
# this doesn't work yet...
# print "LOOK HERE: ", $#{two_d[0]}, "\n";
@arr1 = ("hi", "hello", "bonjour");
@arr2 = ("bye", "bye now", "arrivaderci", "au revoir");
@two_d = (@arr1, @arr2);
print "largest array index of \@two_d: $#two_d\n";
print "\@two_d[0]: @two_d[0]\n";
# here's a hash of hashes --- inspired by:
# http://tihlde.org/~pergh//perlfaq/5.2.html
%hash_of_hashes = (
pwds, { "st10", "yeahright", "dt5", "naah" },
foods, {"chocolate", 13, "fish", 287 },
names, {"st10", "Sharon Tuttle", "aeb3", "Ann Burroughs" }
);
print "LOOKY HERE!!!\n";
print "$hash_of_hashes{foods}->{\"fish\"}", "\n";