mhearse has asked for the wisdom of the Perl Monks concerning the following question:
while (<>) { chomp; s/ //g; tr/a-z/A-Z/; } if (/^GRD/) { @GRD = split /,"?|""?/; while (@GRD) { attribs (\@GRD, 6); field (\@GRD, 1, \@GRDF1); field (\@GRD, 2, \@GRDF2); field (\@GRD, 3, \@GRDF3); field (\@GRD, 4, \@GRDF4); field (\@GRD, 5, \@GRDF5); field (\@GRD, 6, \@GRDF6); last; } } elsif (/^\s*$/) { next; } elsif (/^\*/) { next; } else { s/\W.*//; chomp $_; warn "$ARGV ling $.: \"$_\" is not a valid APG command!\n"; } close FH if eof; close ARGV if eof; } sub field { my ($cmd, $num, $fld) = @_; $max = $#$fld; for ($i = 0; $i <= $max; $i++) { if (@$cmd[$num] eq @$fld[$i]) { last; } elsif (@$cmd[$num] eq "") { last; } elsif ($i == $max) { print "$ARGV line $.: \"@$cmd[$num]\" is not valid for @$cmd[ +0] field $ num.\n"; last; } } } sub attribs { my ($cmd, $book) = @_; my $given = $#$cmd; if ($given != $book) { warn "$ARGV line $.: \"@$cmd[0]\" incorrect number of attributes +. There s hould be $book.\n"; } } BEGIN { @GRDF1 = qw(G Y); @GRDF2 = qw(B); @GRDF3 = @TBLB2; @GRDF4 = @TBLB3; @GRDF5 = qw(S U); @GRDF6 = @MONEY; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Code review
by dws (Chancellor) on Sep 18, 2003 at 03:58 UTC | |
by Abigail-II (Bishop) on Sep 18, 2003 at 09:27 UTC | |
by mhearse (Chaplain) on Sep 18, 2003 at 04:41 UTC | |
|
Re: Code review
by Plankton (Vicar) on Sep 18, 2003 at 04:47 UTC | |
|
Re: Code review
by InfiniteSilence (Curate) on Sep 18, 2003 at 21:50 UTC | |
|
Re: Code review
by mhearse (Chaplain) on Sep 18, 2003 at 03:41 UTC |