programming-examples/perl/Hash/Using variable as the key to get the value stored in a hash.pl

15 lines
204 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl -w
use strict;
my $who = "C";
my %where = (
A => "AA",
B => "BB",
C => "CC",
D => "DD"
);
print $where{A}, "\n";
print "$who lives in $where{$who}\n";