#!/usr/bin/env perl use utf8; use Utils; use strict; use warnings; MAIN: { my $dictionary = {}; print "dictionary size: ", scalar(keys(%$dictionary)), "\n"; print "dictionary is ", (!scalar(%$dictionary) ? "empty" : "not empty"), "\n"; $dictionary->{"apple"} = "red"; $dictionary->{"banana"} = "yellow"; $dictionary->{"cantaloupe"} = "orange"; $dictionary->{"dragonfruit"} = "red"; $dictionary->{"elderberry"} = "purple"; print "dictionary size: ", scalar(keys(%$dictionary)), "\n"; print "dictionary is ", (!scalar(%$dictionary) ? "empty" : "not empty"), "\n"; print "bananas are ", $dictionary->{"banana"}, "\n"; my $x = "dragonfruit"; if (exists $dictionary->{$x}) { print $x, " are ", $dictionary->{$x}, "\n"; } else { print "Can't find ", $x, "\n"; } $x = "fig"; if (exists $dictionary->{$x}) { print $x, " are ", $dictionary->{$x}, "\n"; } else { print "Can't find ", $x, "\n"; } $x = "elderberry"; delete($dictionary->{$x}); if (exists $dictionary->{$x}) { print $x, " are ", $dictionary->{$x}, "\n"; } else { print "Can't find ", $x, "\n"; } print Utils::mapToString($dictionary), "\n"; }