1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
use strict;
use warnings;
my $file = shift @ARGV or die ("You must give a file as input\n");
my $post_id = $1;
my $start_post = 0;
my $post = '';
open (F, $file) or die("unable to open file $file\n");
while (my $line = <F>)
{
chomp $line;
if ($start_post) {
if ($line =~ /<\/td>/) { $start_post = 0; } else {$post.=$line."\n"; }
}
if (($line =~ /<td bgcolor=#DF9309>/)) { $start_post = 1; }
}
close (F);
$post =~ s/<br \/>//g;
$post =~ s/\ / /g;
open (fd,'>test.txt') or die("unable to open file text.txt");
print fd "[$post_id]\n$post\n";
close(fd);
print "[$post_id]\n$post\n"; |
Partager