new-words
view grep-sentences.pl @ 23:4b9d13c78de2
minifix; chars in vim iskeyword
author | Igor Chubin <igor@chub.in> |
---|---|
date | Sun May 16 22:16:31 2010 +0300 (2010-05-16) |
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 }