new-words

view grep-sentences.pl @ 19:416394a87d9f

minifix
author Igor Chubin <igor@chub.in>
date Tue Apr 20 21:15:19 2010 +0400 (2010-04-20)
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 }