You need to specify the filehandle when you print, the default is STDOUT.
text_h => [sub{ print OUT shift;}, 'dtext'],
start_h => [sub{ print OUT shift;}, 'text'],
end_h => [sub{ print OUT shift;}, 'text']);
...At least I think that should work.
Rob
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Friday, March 07, 2003 11:43 AM
To: [EMAIL PROTECTED]
Subject: print output from HTML::Parser
Hi all
perl script below works, and does what I hoped it would, but I don't seem
to understand how to get it to print out the result to a new file as
opposed to stdout.
Thanks for any help
#!/usr/bin/perl -w
use strict;
use HTML::Parser;
open(OUT, ">/share/file1") || die "Cannot open /share/file1: $!\n";
my $html = HTML::Parser->new(
api_version => 3,
text_h => [sub{ print shift;}, 'dtext'],
start_h => [sub{ print shift;}, 'text'],
end_h => [sub{ print shift;}, 'text']);
$html->ignore_tags(qw(!? table body span img p br hr td tr font i b h1 a));
$html->parse_file("/share/input.txt");
$html->eof;
close(OUT);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]