eq "y", "y\n".
if ($choice =~ /^[Yy]/), Y y Y .
<STDIN> STDIN. use strict; use warnings; . , $value $choice, :
my $value = '';
my $choice = '';
. , , , .
use strict;
use warnings;
some_routine();
sub some_routine {
my $value = '';
my $choice = '';
print "Enter a number to select (1) Apple (2) Mango (3) grapes:";
$value = <STDIN>;
if($value !~ /[1-3]/ ) {
print "The input is not valid!";
print "Do you want to continue selecting a fruit again (Y or N)?";
$choice = <STDIN>;
if( $choice =~ /[Yy]/) {
some_routine();
} else {
exit;
}
}
}