in reply to Finding recurring phrases
Load your document as one big string and search that,
open my $fh, '<', 'target.txt'; ## open your file my $file; { local $/ = undef; ## disable the line seperator variable. $file = <$fh>; ## load your file to a string. close $fh; ## close your file } my $phrase = qr{ ## begin phrase Leonardo \s+ ## needed to avoid weird whitespace issues da \s+ ## needed to avoid weird whitespace issues Vinci }gxms; ## match all occurences of our phrase # Returns an array with all the matches my @matches = $file =~ $phrase; # Returns a count of how many matches you had for your string print "Found " . @matches . " matches\n";
|
|---|