Narbawlz has asked for the wisdom of the Perl Monks concerning the following question:
Im trying to write a menu driven Perl script and I just cant figure out how to do a "Go Back" or an "Exit" option. Below is the perl code Ive written so far. Any help would be great!"
#!/usr/bin/perl -w use strict; use Term::ANSIColor qw(:constants); print GREEN, "------------------------------------\n", RESET; print YELLOW, " Options \n", RESET; print GREEN, "------------------------------------\n", RESET; print "\n"; print "\n"; print GREEN, "1. Adtran\n", RESET; print GREEN, "2. Alcatel\n", RESET; print GREEN, "3. Calix\n", RESET; print GREEN, "4. Juniper\n", RESET; print RED, "5. Exit\n", RESET; print "\n"; print "\n"; print YELLOW, "Selection : ", RESET; my $selection = <>; chomp ($selection); print "\n"; if ($selection == 1) { print "\n"; print GREEN, "------------------------------------\n", RESET; print YELLOW, " Adtran \n", RESET; print GREEN, "------------------------------------\n", RESET; print "\n"; print "\n"; print GREEN, "1. Adtran 1148V\n", RESET; print GREEN, "2. Adtran 1100F\n", RESET; print YELLOW, "3. Go Back\n", RESET; print RED, "4. Exit\n", RESET; print "\n"; print "\n"; print YELLOW, "Selection : ", RESET; my $select_Adtran = <>; chomp ($select_Adtran); print "\n"; if ($select_Adtran == 1) { print "1148V Options\n"; } if ($select_Adtran == 2) { print "1100F Options\n"; } if ($select_Adtran == 3) { print "Go Back a Screen\n"; } if ($select_Adtran == 4) { print "Exit\n"; } } if ($selection == 2) { } if ($selection == 3) { } if ($selection == 4) { } if ($selection == 5) { }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: New to Perl and need help
by choroba (Cardinal) on Nov 01, 2017 at 23:16 UTC | |
|
Re: New to Perl and need help
by NetWallah (Canon) on Nov 02, 2017 at 04:22 UTC | |
by kcott (Archbishop) on Nov 02, 2017 at 07:11 UTC | |
|
Re: New to Perl and need help
by jahero (Pilgrim) on Nov 02, 2017 at 08:21 UTC | |
|
Re: New to Perl and need help
by kcott (Archbishop) on Nov 02, 2017 at 07:34 UTC |