Hi
I am trying to write an interactive perl script which will check the commandl line for a message and if the check is successful it will assign 'yes' otherwise will take it from the <STDIN>. Based on the answer, if it is 'yes' the script should continue else it would take the necessary action.
Please refer to the code below which I am trying
use Term::ReadLine; # Initialize the term variable for the keyborad input my $TERM = new Term::ReadLine 'Installer'; my $OUT = $TERM->OUT || \*STDOUT; my $prompt = "Would you like to continue\n"; my $ans; $ans = ($TERM->readline($prompt)) ? : 'yes' :<STDIN> ; chomp($ans); print "ans is $ans \n"; if($ans =~ /yes/) { print "yes and continue\n"; } else { print "no and take action\n"; }
In reply to how to take user input from command line and continue by simonz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |