#! /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 (INFILE, $ARGV[0]) or die "unable to open file"; open (OUTFILE, ">$ARGV[1]"); my $line; my @array; my $self=0; my $choice; while () { $line = $_; chomp ($line); @array = (); @array = split (/\s+/, $line); if (($array[1] =~ /^Happy/) && ($array[2] <30)) { ; $self = "$array[1]\t$array[2]\n"; # if i print $self here it prints out all of the results from that catergory } print STDOUT "Please select the catergory of results that you wish to see;\n\n\t 1. Hello\n\t2.Happy \n\t3. unhappy \n\t4.grumpy \n\n"; $choice = ; # remove the newline character from the chosen option. chomp $choice; if ($choice eq 1) { # if i print $self here it only prints one result, not the entire list print "$self\n"; } close OUTFILE;