CPU: Perl, Fall 2005 Perl, Week 4: More Arrays, Context, Subroutines, Lexical Variables #43

Try it

$capitals{"Ohio"} = "Columbus";
$capitals{"Utah"} = "Salt Lake City";
foreach my $state (qw( Ohio Utah )) {
    print "The capital of $state "
        . "is $capitals{$state}\n";
}
Copyright © 2005 Ian Langworth