I want to ask the user multiple questions. I have two types of questions: Y/N or filename input. I\'m not sure how to place this all into a nice if
structure. And I
You can use Sub Routines. This helps you visibly and logically keep everything in-line. for instance
&main();
sub main {
print "Do you want to import a list(Y/N)";
my $input = ;
chomp $input;
if($input =~ m/^[Y]$/i) {
&importfile();
} elsif ($input =~ m/^[N]$/i) {
print "you said no";
} else {
print "Invalid option";
}
}
sub importfile
{
print "file name please ";
my $file = STDIN;
# import and process the file here.....
&main();
}
So you can import at many files this way.