in reply to Re: How do i create different commands for different user inputs
in thread How do i create different commands for different user inputs

Your code only checks for "yes". If the user entered "Sure!", you would get the "Hmm - that stinks. You need a blue rock." answer. Better test for "no" too:
$|++; # make sure we turn off buffering. print "Is the rock blue? yes or no: "; my $response = <STDIN>; chomp $response; # get rid of the enter key if ($response eq 'yes') { print "Great, it's blue!\n"; } elsif ($response eq 'no') { print "Hmm - that stinks. You need a blue rock.\n"; } else { print "yes or no, boy!\n"; }

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

  • Comment on Re^2: How do i create different commands for different user inputs
  • Download Code