Sorry all, the OS is Solaris 8 and the version of Perl is 5.005_03. I know, it's outdated, trust me I know this, but there is nothing I am able to do about it.

A little more about the script... Basically, it is entirely command line. You ssh into the server and then you load up the menu. There is no X session at all. It is entirely command line. Now, basically the idea is that we start with a menu and we end with a $script and $infile variable, which are then passed to another script. So we're building a command line is all the menu is really doing. However, there is a lot of input and the menu changes based on user input. Again, a little revised version here, but this is what I have thus far:
#!/usr/bin/perl use strict; use Menu; my $username=getlogin(); my $infile="/tmp/$username.inFile"; my ($script,$infile=mainMenu($infile);
sub mainMenu { my $infile=shift; my ($choice,$notice); while (1) { system("clear"); print BOLD BLUE <<EOF; PLEASE CHOOSE AN OPTION FROM BELOW EOF print GREEN <<EOF; (A) Account Administration ------------------------------- EOF if ($notice ne "") { print RED "\n\n$notice\n\n"; $notice=""; } my $choice=getInput("Please enter your choice > "); if ($choice =~ /a/i) { accountMenu($infile); last; } else { $notice="INVALID OPTION!"; next; } } } sub accountMenu { my $infile=shift; my ($notice,$choice); while (1) { system("clear"); print BOLD BLUE <<EOF; PLEASE CHOOSE AN OPTION FROM BELOW EOF print GREEN <<EOF; (1) Add Account(s). ------------------------------------------------- (M) Back to Main Menu. EOF if ($choice == 1) { addAccount($infile); last; } else { $notice="INVALID OPTION"; next; } }
sub getInput { my $message = shift; my $return; print "$message"; chomp($return=<STDIN>); return $return; }
sub addAccount { my $infile = shift; while (1) { system("clear"); print BOLD BLUE <<EOF; PLEASE CHOOSE AN OPTION FROM BELOW EOF print RED <<EOF; (1) Load User File. (2) Manually Enter Each User. ------------------------------------------------- (A) Back to Account Administration Menu. (M) Back to Main Menu. (E) Exit. EOF if ($notice ne "") { print RED "\n\n$notice\n\n"; $notice=""; } my $choice=getInput("Please enter your choice > "); if ($choice == 1) { loadFile(); last; } elsif ($choice == 2) { manuallyEnterUser(); last; } elsif ($choice =~ /a/i) { accountMenu(); } elsif ($choice =~ /m/i) { mainMenu(); } elsif ($choice =~ /e/i) { exit(0); } else { $notice="INVALID OPTION"; next; } } }
Now, the user can then load a file, at which point they type in full path to file, and then all options are validated and if file is good then their infile gets returned as the infile, and script gets returned. If a line in user infile is not valid then they must fix the error. Anyway, this is a huge convuluted way of doing a simple task, and I just know there is an easier way of doing this.

In reply to Re^2: Building a Perl Menu by walkingthecow
in thread Building a Perl Menu by walkingthecow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.