Mega Code Archive

 
Categories / Perl / Hash
 

Hash List Assignment

#!/usr/local/bin/perl print "\n\n"; %priceList = (     "A"=>2.92,     "B"=>3.31,     "C"=>1.00,     "D"=>1.01,     "E"=>2.87,     "F"=>2.56, ); printAA(%priceList); print "$priceList{'A'}\n"; %priceList = (     1=>28.92,     2=>36.31,     3=>124.00,     4=>178.01,     5=>205.87,     6=>24.56, ); print "Or like this $priceList{1} \n\n"; printAA(%priceList); sub printAA {     my %myPriceList = @_;     foreach $key (keys(%myPriceList)){         print "$key is $priceList{$key}\n";     }     print "\n\n"; }