Hi, i am writing a script that sort elements of an array into certain criteria, and then asks the user what catergory
they want to see. I have given a snippet of code here, my problem is that i want to print out every value of a certain criteria when the user asks to see it, however my print statement only prints a single value.
Am i not passing the whole array into the scalar variable?? is it because it isn't nested in the loop correctly?? - if i put the whole thing into the loop i end up asking the same question over and over to the user.
what am i doing wrong??
#! /usr/local/bin/perl -w
$num_of_params = @ARGV;
if ($num_of_params < 2)
die ("\n You haven't entered enough parameters !!\n\n");
open (INFILE, $ARGV) or die "unable to open file";
open (OUTFILE, ">$ARGV");
$line = $_;
@array = ();
@array = split (/\s+/, $line);
if (($array =~ /^Happy/) && ($array <30))
$self = "$array\t$array\n";
# if i print $self here it prints out all of the results from that cat
print STDOUT "Please select the catergory of results that you wish t
1. Hello\n\t2.Happy \n\t3. unhappy
$choice = <STDIN>;
# remove the newline character from the chosen option.
if ($choice eq 1)
# if i print $self here it only prints one result, not the entire list