I am having trouble with a PERL Script I'm writing to take 1 smaller file and compare each line with the contents of a larger file. I am using a positive look-behind regex statement to find the match and give me just the rest of the line.
When I run the code I see all of the elements of @elements print, with no matches printed until the last line. Without displaying sensitive data this is what I see.
$element[0]
.
.
.
$element[30]
[match]
.
.
.
.
.
The matches for element[30] list perfectly, but I am expecting this to happen for each element, not just last element in the array. Here is my code:
use strict;
use warnings;
open(my $in, "<", "call_types.txt");
my @elements = <$in>;
close $in;
open(my $in, "<", "DNIS.cfg");
my @dnis = <$in>;
close $in;
foreach my $call(@elements){
print "$call\n";
foreach my $dn(@dnis){
if($dn =~ /(?<=$call ).*/){
print "$&\n";
}
}
print "\n";
}