#!/usr/local/bin/perl #HiWally in Perl #non-Cgi version #Andy Harris, 10/97 #note: the uc function only works in perl 5.0 and later. #in earlier compilers. (like the one on Klingon) take out uc references. #or comment out the uc version and use the alternate version. #alternate versions use pattern matching. Just trust me on this for now. $userName = ""; #string for user's name # note that ne is != for string comparisons while(uc($userName) ne "QUIT"){ #alternate version of above line: # while (!$userName =~ m/quit/i){ print ("What is your name? (or QUIT) "); # we get stuff from the keyboard by copying it from $userName = ; chop($userName); # eq is string version of == if(uc($userName) eq "WALLY"){ #alternate form of above line: #if ($userName =~ m/wally/i){ print("You PIG!!! \n"); } else { #this part happens when userName is not wally if (uc($userName) eq "QUIT"){ #alternate version of above line: # if ($userName =~ m/quit/i){ print ("Goodbye! \n"); } else { #this part happens when userName is not wally OR quit print ("Do I know you $userName? \n"); } #end quit if } # end wally if } #end while ##### sample output ##### # ds9{aharris}2: hiWally.pl # What is your name? (or QUIT) Andy # Do I know you Andy? # What is your name? (or QUIT) Wally # You PIG!!! # What is your name? (or QUIT) quit # Goodbye! # ds9{aharris}3: