File: htitle

package info (click to toggle)
libhtml-parser-perl 3.83-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 944 kB
  • sloc: ansic: 7,624; perl: 1,669; makefile: 13
file content (21 lines) | stat: -rwxr-xr-x 461 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl

# This program will print out the title of an HTML document.

use strict;
use warnings;
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";