new-words

view grep-sentences.pl @ 10:25bc92026f32

LICENSE GPLv3 added
author Igor Chubin <igor@chub.in>
date Wed Mar 31 22:38:03 2010 +0300 (2010-03-31)
parents 9345cc05fdd1
children c6efd17741aa
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 @sentences=split /\./, $text;
13 for (@sentences) {
14 s/^\s*//;
15 s/\s*$//;
16 s/\[[0-9]+\]//g;
17 s/\s+/ /g;
18 print "$_.\n\n" if /\b$regexp\b/;
19 }
20 }