Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#! /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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: struggling with sub-routines
by arturo (Vicar) on Jun 18, 2002 at 13:51 UTC | |
|
Re: struggling with sub-routines
by robobunny (Friar) on Jun 18, 2002 at 13:45 UTC | |
by Anonymous Monk on Jun 18, 2002 at 14:10 UTC | |
|
Re: struggling with sub-routines
by r0b (Pilgrim) on Jun 18, 2002 at 16:19 UTC | |
by Anonymous Monk on Jun 19, 2002 at 13:17 UTC | |
by r0b (Pilgrim) on Jun 19, 2002 at 16:34 UTC | |
by Anonymous Monk on Jun 20, 2002 at 09:25 UTC |