walkingthecow has asked for the wisdom of the Perl Monks concerning the following question:
Account Menusub mainMenu { my ($choice,$notice); while (1) { system("clear"); $choice=displayMenu("main",$notice); if ($choice =~ /a/i) { accountMenu(); last; } elsif ($choice =~ /s/i) { serverMenu(); last; } elsif ($choice =~ /m/i) { miscMenu(); last; } else { $notice="INVALID OPTION!"; next; } } }
addAccountsub accountMenu { my ($notice,$choice); while (1) { $choice=displayMenu("accountMenu",$notice) if ($choice == 1) { changePassword(); last; } elsif ($choice == 2) { addAccount(); last; } else { $notice="INVALID OPTION"; } } }
As you can see right now the code is not returning the script or infile, but really at this point I have so many function calls for just one option that I am just completely lost here. Is there a better way to do this? A good module anyone can recommend? Anything??sub addAccount { while (1) { displayMenu("add"); if ($choice == 1) { my $tempInFile=getInput("PLEASE ENTER FULL PATH TO INPUT F +ILE > "); my $csv = Text::CSV->new(); open (CSV, "<$tempInFile") or die "COULD NOT OPEN $tempInF +ile ($!)\n"; while (<CSV>) { if ($csv->parse($_)) { my @columns = $csv->fields(); validateOptions("add","$infile",@columns); } else { my $err = $csv->error_input; print "Failed to parse line: $err"; } } close CSV; last; } elsif ($choice == 2) { manuallyEnterUser("add"," "); last; } elsif ($choice =~ /a/i) { accountMenu(); } elsif ($choice =~ /m/i) { mainMenu(); } elsif ($choice =~ /e/i) { exit(0); } else { $notice="INVALID OPTION"; next; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Building a Perl Menu
by Utilitarian (Vicar) on Apr 28, 2009 at 10:03 UTC | |
|
Re: Building a Perl Menu
by leocharre (Priest) on Apr 28, 2009 at 15:01 UTC | |
|
Re: Building a Perl Menu
by Bloodnok (Vicar) on Apr 28, 2009 at 17:02 UTC | |
by walkingthecow (Friar) on Apr 29, 2009 at 00:39 UTC | |
by Bloodnok (Vicar) on Apr 29, 2009 at 09:40 UTC |