print "Are you sure? [y]"; chomp(my $ans = <STDIN>); $ans ||= "y"; if ($ans =~ m!^y(es)?!) { # do something } else { # do otherthing }
Update: added missing chomp thanks to cog. Added some more code as asked by virtualsue.
Alberto Simões
In reply to Re: writing to stdin
by ambs
in thread writing to stdin
by neandertalc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |