Lists, Arrays, and Hashes
Hash Lookup
A hash maps keys to values, and a lookup reads the value for one key.
Hash Lookup
hash_lookup.pl
use strict;
use warnings;
my %scores = (
perl => 95,
go => 88,
ruby => 91,
);
my $key = ;
my $value = $scores{$key};
my $found = exists $scores{$key} ? "yes" : "no";
print "key=$key\n";
print "found=$found\n";
print "value=$value\n";
use strict;
use warnings;
my %scores = (
perl => 95,
go => 88,
ruby => 91,
);
my $key = ;
my $value = $scores{$key};
my $found = exists $scores{$key} ? "yes" : "no";
print "key=$key\n";
print "found=$found\n";
print "value=$value\n";
use strict;
use warnings;
my %scores = (
perl => 95,
go => 88,
ruby => 91,
);
my $key = ;
my $value = $scores{$key};
my $found = exists $scores{$key} ? "yes" : "no";
print "key=$key\n";
print "found=$found\n";
print "value=$value\n";
hash lookup
A hash lookup uses a key inside braces to read one stored value.