Hi, i have written a script which is not working quite as i would like. It reads in a file of data which it catergorizes and it also has a menu for the user to choose a catergory to look at. My problems are that i have written a do-until loop to go back to the menu once the user has finished looking at one catergory - although it does go back to the menu it doesn't display the data when another option has been selected. My second problem is that in order to catergorize the data i am using regular expression matches - however they are not extracting everything that matches that particular reg exp. Can anyone point out where i have gone wrong?
#! /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 \n\n"); } open (FH, $ARGV[0]) or die "unable to open file"; open (OUTFILE, ">$ARGV[1]"); # declare some variables. my $line; my @array; my $first=0; my $second=0; my $third; my $fourth; my $fifth; my $others; do { print STDOUT "\nPlease select the catergory of results that you wish t +o see;\n\n \t1. first \n\t2. second \n\t3. third \n\t4. fourth \n\t5. others\n\t6 +. Exit program\n\n"; $choice = <STDIN>; chomp $choice; print "\nIdentifier \t\t%identity \n\n"; while (<FH>) { $line = $_; chomp ($line); @array = (); @array = split (/\s+/, $line); $array[8] =~ s/\%//g; if ((($array[1] =~ m{/:yes\|\w+\|\w+}) || ($array[1] =~ m{/:maybe\|\w ++\|\ w+})) && ($array[8] > 95) && ($choice eq 1)) { $first = "$array[1]\t$array[8]\n"; print $first; print OUTFILE $first; } elsif ((($array[1] =~ m{/:no\|\w+\|\w+}) || ($array[1] =~ m{/:noway\ |\w+\|\w+})) && ($array[8] > 95) && ($choice eq 2)) { $second = "$array[1]\t$array[8]\n"; print $second; print OUTFILE $second; } elsif ((($array[1] =~ m{/:definatley\|\w+\|\w+}) || ($array[1] =~ m{ +/:highly\|\w +\|\w+})) && ($array[8] < 95) && ($choice eq 3)) { $third = "$array[1]\t$array[8]\n"; print $third; print OUTFILE $third; } elsif ((($array[1] =~ m{/:no\|\w+\|\w+}) || ($array[1] =~ m{/:noway \|\w+\|\w+})) && ($array[8] < 95) && ($choice eq 4)) { ; $fourth = "$array[1]\t$array[8]\n"; print $fourth; print OUTFILE $fourth; } elsif (($choice eq 5) && (($array[1] =~ m{/:perhaps\|\w+\|\w+}) || ($ +array[1] =~ m{ /:possibly\|\w+\|\w+}) || ($array[1] =~ m{/:unsure\|\w+\|\w+}) || ($ar +ray[1] =~ m{/: maybe\|\w+\|\w+})) && ($array[8] > 0)) { $others = "$array[1]\t\t$array[8]\n"; print $others; print OUTFILE $others; } elsif ($choice eq 6) { last; } } } until ($choice eq 6); close OUTFILE;
I really hope that someone can teach me something.

In reply to user input / reg exp's 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.