#!/usr/bin/perl
use 5.010;
use warnings;
open DD, '<', 'file.txt';
while ( <DD> ) {
chomp;
if ( /(\w+)/ ) {
$pattern .= "_$1";
}
$matches{"$pattern"} = 1;
}
close DD;
open DDX, '<', 'file.txt';
while ( <DDX> ) {
chomp;
if ( /(\w+)/ ) {
$patternx .= "_$1";
}
foreach $m ( keys %matches ) {
$count = 1;
while ( $count > 0 ) {
if ( ( "$m" =~ /"$patternx"/ ) x $count ) { # expression thats failing
$count += 1;
} else {
$matched{"$m"} = $count;
$count = 0;
}
}
}
}
close DDX;
foreach ( sort keys %matched ) {
print "$matched{$_}: $_\n";
}
[\code]
(This post was edited by omega on Dec 28, 2012, 6:45 PM)