in reply to parsing with two files
use warnings; use strict; use Data::Dumper; # store codes in hash for fast lookup my %code; { open(my $FH1, "<", "file1") or die($!); chomp() and ++$code{$_} while <$FH1>; } # read in chunks that end with 'Code id -' my %data; { local $/ = "Code id -"; open(my $FH2, "<", "file2") or die($!); while (<$FH2>) { /^(\d+)-.*\nEvent id -(\d+)-/s or next; $data{$1} = $2 if $code{$1}; } } print Dumper(\%data); __END__ $VAR1 = { '12131' => '123443111131', '46566' => '445778441211' };
|
|---|