mdhat13

exercise #2 (display list elements according to user input)

Feb 17th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.40 KB | None | 0 0
  1. #!C:\Strawberry\perl\bin
  2. use warnings;
  3.  
  4. $stop = 0;
  5. until ($stop != 0) {
  6.  
  7.     @list = qw(a b c d e);
  8.    
  9.     print "please enter a number between 0 and 4\n";
  10.  
  11.     $entry = <STDIN>;
  12.     print "you entered $list[$entry]\n";
  13.  
  14.     print "would you like to view another entry?(yes/no)\n";
  15.     $answer = <STDIN>;
  16.     chomp $answer;
  17.    
  18.     if ($answer eq "no") {
  19.         print "\n exiting.......\n";
  20.         $stop += 1;
  21.     }
  22.        
  23.        
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment