#### Program: # The Acronym Expander Program $acronym_to_name{"CGI"} = "Common Gateway Interface"; $acronym_to_name{"DHTML"} = "Dynamic HyperText Markup Language"; $acronym_to_name{"HTML"} = "HyperText Markup Language"; $acronym_to_name{"XHTML"} = "Extensible HyperText Markup Language"; $acronym_to_name{"perl"} = "Practical Extraction and Report Language"; for (;;) { print "enter an acronym: "; $acronym = ; chomp($acronym); if ( $acronym eq "" ) { last; } $name = $acronym_to_name{$acronym}; if ( $name eq "" ) { print " We have no listing for $acronym\n\n"; } else { print " $name\n\n"; } } __END__ #### Sample Dialogue: Please enter an acronym: CGI Common Gateway Interface Please enter an acronym: DHTML Dynamic Hypertext Markup Language #### Notes on Code Fragments: $acronym_to_name{"CGI"} = "..."; # sets the entry for CGI to the value ... (ie. the entry in the hash acronym_to_name) { } # the { } tells you this is a hash $name = $acronym_to_name("CGI"); # sets $name to the value of the entry for CGI $name = $acronym_to_name($acronym} # sets $name to the value of the entry for $acronym # if $acronym is equal DHTML, # $name will be set to "Dynamic HyperText Markup Language"; ############################# that's all folks #################################