Does this, untested, code help?
use strict; use warnings; use Getopt::Long; my ( $cfg,$files ); my $output = 'Output.summary'; GetOptions ('cfg=s' => \$cfg, 'rtl=s' => \$files); open my $fh1, '<', $cfg or die "Can't open $cfg: $!"; open my $fh2, '<', $files or die "Can't open $files: $!"; open my $fh3, '>', $output or die "Can't open $output: $!"; # Read the config file first # less memory required assuming it is the smaller file my @patterns; while (<fh1>) { next unless /\S/; chomp; push @patterns, $_; } my %results; # Now look through the other file while (my $data = <$fh2>) { next unless /\S/; chomp $data; for my $pattern (@patterns) { if (index $data, $element) { # don't need regex for exact match $results{$data} = "matches $element"; last; } else { $results{$data} = "doesn't match"; } } } while (my($key,$value) = each(%results)) { print $fh3 "$key => $value\n"; }
Cheers,
R.
In reply to Re: Looping two files differently
by Random_Walk
in thread Looping two files differently
by noob_mas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |