Hi, while testing the program (runs in DOS), I thought "if someone hits enter without typing a letter before, what happens?"
I tested and the script ends.. Is this normal, or how can I avoid this?
[CODE=perl]print "To which analytical division is the study belonging to?\n\n";
print "\ti: Immunology\n";
print "\tc: Chemistry\n";
print "\tq: Quit\n";
print "\n\tYour choice: ";
chomp (my $group = <>);
my @group_list = ("i","c","q" );
if (!(grep (/$group/i, @group_list))){
do{
print "\n\nYour choice is not valid.\nPlease enter a valid choice: (i/c/q)";
print "\n\tYour choice: ";
chomp ($group = <>);
} until (grep (/$group/i, @group_list));
}[/CODE]
I tested and the script ends.. Is this normal, or how can I avoid this?
[CODE=perl]print "To which analytical division is the study belonging to?\n\n";
print "\ti: Immunology\n";
print "\tc: Chemistry\n";
print "\tq: Quit\n";
print "\n\tYour choice: ";
chomp (my $group = <>);
my @group_list = ("i","c","q" );
if (!(grep (/$group/i, @group_list))){
do{
print "\n\nYour choice is not valid.\nPlease enter a valid choice: (i/c/q)";
print "\n\tYour choice: ";
chomp ($group = <>);
} until (grep (/$group/i, @group_list));
}[/CODE]
Comment