HTML
.
1 #!/usr/bin/perl -w 2 use strict; 3 use Term::ANSIScreen qw/:constants/; 4 5 my $bold = BOLD(); 6 my $clear = CLEAR(); 7 my $line = 1; 8 9 # read paragraph 10 local $/ = ".\n"; 11 while (my $par = <>) { 12 next unless $par =~ s{ 13 \b # start word ... 14 ([a-z]+) # grab word in $1 and \1 15 ( # save the tags and spaces in $2 16 (\s|<[^>]+>)+ # spaces or HTML tags 17 ) 18 (\1\b) # repeated word in $4 19 }!$bold$1$clear$2$bold$4$clear!igx; 20 21 $par =~ s/^/"$ARGV(".$line++."): "/meg; # insert filename and line number 22 23 print $par; 24 }
Sigue un ejemplo de uso:
pl@nereida:~/Lperltesting$ cat -n t.t 1 one one 2 nothing rep 3 is two three 4 three four 5 pl@nereida:~/Lperltesting$ ./repeatedwords2.pl t.t t.t(1): one one t.t(2): nothing rep t.t(3): is two three t.t(4): three four t.t(5):