#! /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]"); my $line; my @array; my $first=0; my $second=0; my $third; my $forth; my $choice; my $others; while (<FH>) { chomp; my @array = split /\s+/; $array[8] =~ tr/%//d; } 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. forth \n\t5. Others etc\ +n\t6. Exit program\n\n"; my $choice = <STDIN>; chomp $choice; print "\n Identifier \t\t%identity \n\n"; catergory ($first); if ($choice eq 1) { print $first; } sub catergory { my @array = @_; if (($array[1] =~ m{/:first\|\w+\|\w+}) && ($array[8] > 95)) { my $first = "$array[1]\t$array[8]\n"; } elsif (($array[1] =~ m{/:second\|\w+\|\w+}) && ($array[8] > 95)) { $second = "$array[1]\t$array[8]\n"; } elsif (($array[1] =~ m{/:third\|\w+\|\w+}) && ($array[8] < 95)) { $third = "$array[1]\t$array[8]\n"; } elsif (($array[1] =~ m{/:forth\|\w+\|\w+}) && ($array[8] < 95)) { $forth = "$array[1]\t$array[8]\n"; } elsif (($choice eq 5) && ($array[1] =~ m{/:other\|\w+\|\w+}) { $others = "$array[1]\t\t$array[8]\n"; } return $first; return $second; return $third; return $forth; return $others; } close OUTFILE;
In reply to struggling with sub-routines by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |