# Written on February 28th, 2003 to illustrate hashing techniques # relevant to PERL assignment one - see the letter4.txt data file. # a,head;b,mouth;c,face;d,nose;... my %schoolHash; $str = "UNI,Panthers;ISU,Cyclones;Iowa,Hawkeyes;USC,Trojans;" . "Idaho,Vandals;Pepperdine,Waves"; @schools = split(/;/, $str); foreach (@schools) { ($schoolName, $mascot) = split(/,/, $_); $schoolHash{ $schoolName } = $mascot; # $schoolName is the key } # $mascot is the value print "\n"; $message = " Mascot for "; foreach $school (keys %schoolHash) { print " $message $school is $schoolHash{ $school } \n"; $message = " "; } print "\n"; math-cs:~/web/151PERL> !pe <--- Searching command history for most perl hashSchools.p recent command that starts with pe -- Mascot for Pepperdine is Waves UNI is Panthers Iowa is Hawkeyes ISU is Cyclones Idaho is Vandals USC is Trojans math-cs:~/web/151PERL>