diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2013-05-08 22:21:52 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2013-05-08 22:21:52 +0000 |
commit | 2f253cfc85ffd55a8acb988e91f0bc5ab348124c (patch) | |
tree | 4734ccd522c71dd455879162006742002f8c1565 /eg/htitle | |
download | HTML-Parser-tarball-master.tar.gz |
HTML-Parser-3.71HEADHTML-Parser-3.71master
Diffstat (limited to 'eg/htitle')
-rwxr-xr-x | eg/htitle | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/eg/htitle b/eg/htitle new file mode 100755 index 0000000..38da5d6 --- /dev/null +++ b/eg/htitle @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +# This program will print out the title of an HTML document. + +use strict; +use HTML::Parser (); + +sub title_handler +{ + my $self = shift; + $self->handler(text => sub { print @_ }, "dtext"); + $self->handler(end => "eof", "self"); +} + +my $p = HTML::Parser->new(api_version => 3, + start_h => [\&title_handler, "self"], + report_tags => ['title'], + ); +$p->parse_file(shift || die) || die $!; +print "\n"; + |