#!/usr/bin/perl -w use strict; my $in = (); # usr input my $exit = 'n'; # done yet? my %acro = ( 'HTML' => "Hypertext Markup Language", 'ICBM' => "Intercontinental Ballistic Missile", 'EEPROM' => "Electronically-erasable programmable read only memory", 'SCUBA' => "Self Contained Underwater Breathing Aparatus", 'FAQ' => "Frequently Asked Questions", 'LCARS' => "Library Computer And Retrieval System", 'NASA' => "National Aeronautical and Space Administration" ); # I personally don't like empty conditions on # while loops. This changed the logic a bit, so # I changed the exit prompt as well. while ($exit !~ /^y/i) { print "\nPlease enter an acronym: "; chomp($in = ); print "\n"; # I'm lazy, and don't want to worry about entering # uppercase acronyms. The uc() changes input to # uppercase automagically. Also, this approach # doesn't loop over every key every time. That's # what a hash is best for -- so you don't have to loop # over everything. if (exists $acro{uc($in)}) { # No need to assign to a temp variable, btw. print "$in is the acronym for ", $acro{uc($in)}, " \n\n"; } else { # I also echo input so if the user mistyped the acronym they # may see the error. print "Sorry. But $in is not an acronym that I recognize!\n"; } print "\nFinished? "; # Your original script didn't have any way to input $exit, so # it went into an infinite loop (I am guessing that was a # transcription error) chomp($exit = ); }