in reply to Perl beginner here, needs a shove in the right direction.
First for the shove in the right direction: It sounds like you might be doing EDI X12 stuff. If so, search CPAN for relevant libraries. Chances are very good you are reinventing a wheel.
Now, these seem like a case where you likely can write some nice, elegant code. Not being familiar entirely with what you are doing, let's go over a quick example:
sub invalid_line { my ($line) = @_; ... return 1 if $invalid; } my @files; # todo, get list of files for my $file (@files) { open FILE '<', $file; if (scalar grep { invalid_line($_) } grep { $_ =~ /^$keyword/ } <FILE> ){ # file is invalid } else { # file is valid } close FILE; }
|
|---|