new-words
view grep-sentences.pl @ 25:d1eb7dc37feb
minifix: -p pages
author | Igor Chubin <igor@chub.in> |
---|---|
date | Mon May 17 14:48:34 2010 +0300 (2010-05-17) |
parents | c6efd17741aa |
children | 7db7bbf96fad |
line source
1 #!/usr/bin/perl
4 $regexp=$ARGV[0];
5 $page=$ARGV[1];
6 #if (open(PAGE, "lynx -dump '$page'|")) {
7 if (open(PAGE, "$page")) {
8 local $/;
9 $text=<PAGE>;
10 $text =~ s@http://[a-zA-Z&_.:/0-9%?=,\#+()\[\]~-]*@@g;
11 $text =~ s@\n@@g;
12 $text =~ s@(Mr|Mrs)\.@\1POINT@g;
13 @sentences=split /[.!?]/, $text;
14 for (@sentences) {
15 s@(Mr|Mrs)POINT@\1.@g;
16 s/^\s*//;
17 s/\s*$//;
18 s/\[[0-9]+\]//g;
19 s/\s+/ /g;
20 print "$_.\n\n" if /\b$regexp\b/;
21 }
22 }