print "Are you sure? [y]"; chomp(my $ans = ); $ans ||= "y"; if ($ans =~ m!^y(es)?!) { # do something } else { # do otherthing }