#Warningt untested
my $answer = <STDIN>;
chomp($answer);
if($answer =~ m/^[y|Y]es$/) {
print "Yes";
}elsif ( $answer =~m/^[n|N]o$/ {
print "no";
}else {
print "undefined value";
}
Christopher Spears wrote:
I'm writing a Perl script where I ask the user a
question similar to:
Would you like to remove this file?
Type y or n.
How do I get Perl to receive the answer and act on it?
I've been looking in some of my books and noticed
two ways of receiving input <STDIN> and <>. What is
the difference between the two?
=====
"I'm the last person to pretend that I'm a radio. I'd rather go out and be a color
television set."
-David Bowie
"Who dares wins"
-British military motto
"The freak is the norm." - "The Infernal Desire Machines of Dr. Hoffman" by
Angela Carter
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>