I would like to know how to prompt the user for an input on the terminal. I have a print statement which asks for 3 choices and use <STDIN> to prompt the user for an input. This code works perfectly with DOS but I need it to work on the terminal. I don't know how to read from terminal. I looked up some shell scripts and it says read CMD but that command doesn't work in Perl.
Code:
print "Choose a means of transportation:\n\n"; print "1. car\n2. bike\n 3. airplane\n\nSelect Option: "; $result = <STDIN>; if ($result == 1) { print "\nYou chose a car\n"; } elsif($result == 2) { print "\nYou chose a bike\n"; } elsif($result == 3) { print "\nYou chose an airplane\n"; } print "\nHave a safe trip!";
Comment