in reply to Efficient regex matching with qr//; Can I do better?
sub slow_match { my($hash_ref_1,$hash_ref_2) = @_; my @text_id = keys %hash2; my @text = values %hash2; while ( my($pattern,$high_lvl_id) = each(%hash1) ) { my $match = qr/\b$pattern\b/; for my $text_index (0..$#text) { if ($text[$text_index] =~ $match) { $$hash_ref_1{$text_id[$index_index]} .= ':'.$high_lvl_id; foreach my $part (split(/\s/,$pattern)) { $$hash_ref_2{$text_id[$text_index]} -> {$part} = 0; } } } } }
|
|---|