Hash List Assignment : Hash Assignment « Hash « Perl






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";
}

   
    
    
    
  








Related examples in the same category

1.Hash hash overwrites
2.Hashes Assignment in action
3.Merge two hash variable