new-words

annotate 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
rev   line source
igor@5 1 #!/usr/bin/perl
igor@5 2
igor@5 3
igor@6 4 $regexp=$ARGV[0];
igor@6 5 $page=$ARGV[1];
igor@5 6 #if (open(PAGE, "lynx -dump '$page'|")) {
igor@5 7 if (open(PAGE, "$page")) {
igor@5 8 local $/;
igor@5 9 $text=<PAGE>;
igor@5 10 $text =~ s@http://[a-zA-Z&_.:/0-9%?=,\#+()\[\]~-]*@@g;
igor@5 11 $text =~ s@\n@@g;
igor@5 12 @sentences=split /\./, $text;
igor@5 13 for (@sentences) {
igor@5 14 s/^\s*//;
igor@5 15 s/\s*$//;
igor@5 16 s/\[[0-9]+\]//g;
igor@5 17 s/\s+/ /g;
igor@5 18 print "$_.\n\n" if /\b$regexp\b/;
igor@5 19 }
igor@5 20 }