Hi, my problem is that i am trying to write a program which allows the users to choose from the menu which set of results to look at, my problem is that i want to give them the option of looking at another set of results after they have finished with the first e.g i want to return to the main menu. See the code below;
#! /usr/local/bin/perl -w use strict; my $num_of_params; $num_of_params = @ARGV; if ($num_of_params < 2) { die ("\n You haven't entered enough parameters f\n\n"); } open (FILE, $ARGV[0]) or die "unable to open file"; open (OUTFILE, ">$ARGV[1]"); my $line; my @array; my $tv=0; my $computers=0; my $exercise; my $food; my $choice; print STDOUT "\nPlease select the catergory of results that you wish t +o see;\n\n\t1. tv \n\t2. computers \n\t3. exercise \n\t4. food\n\n"; $choice = <STDIN>; # remove the newline character from the chosen option. chomp $choice; # when the results are printed to the screen, ensure the user understa +nds what # the data is - this print statement does this. print "\nchoice \t\t value \n\n"; while (<FILE>) { $line = $_; chomp ($line); @array = (); @array = split (/\s+/, $line); if ((($array[1] =~ m{/any\|\w+\|\w+}) || ($array[1] =~ m{/:other\| +\w+\|\w+})) && ( $array[8] > 95) && ($choice eq 1)) { $tv = "$array[1]\t$array[8]\n"; print $tv; print OUTFILE $tv; } if ((($array[1] =~ m{/any2\|\w+\|\w+}) || ($array[1] =~ m{/:other2\ +|\w+\|\w+})) && ($array[8] > 95) && ($choice eq 2)) { $computers = "$array[1]\t$array[8]\n"; print $computers; print OUTFILE $computers; } + if ((($array[1] =~ m{/any\|\w+\|\w+}) || ($array[1] =~ m{/:other3\|\w ++\|\w+})) && ($array[8] < 95) && ($choice eq 3)) { $exercise = "$array[1]\t$array[8]\n"; print $exercise; print OUTFILE $exercise; } if ((($array[1] =~ m{/any\|\w+\|\w+}) || ($array[1] =~ m{/:other4\| +\w+\|\w+})) && ($array[8] < 95) && ($choice eq 4)) { $food = "$array[1]\t$array[8]\n"; print $food; print OUTFILE $food; } print "\nWould you like to go back to the main menu? (y/n/q)"; $choice2 = <STDIN>; if ($choice2 eq 'y') { print "\nPlease select the catergory of results that you wish to see;\ +n\n\t1. tv \n\t2. computers \n\t3. exercise \n\t4. food \n\n"; } if ($choice2 eq 'n') { exit; } if ($choice2 eq 'q') { exit; } close OUTFILE;
}

In reply to nested loops problem by Anonymous Monk

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.