home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / libhtml-parser-perl / examples / htitle < prev   
Encoding:
Text File  |  2001-03-26  |  434 b   |  22 lines

  1. #!/usr/bin/perl
  2.  
  3. # This program will print out the title of an HTML document.
  4.  
  5. use strict;
  6. use HTML::Parser ();
  7.  
  8. sub title_handler
  9. {
  10.     my $self = shift;
  11.     $self->handler(text => sub { print @_ }, "dtext");
  12.     $self->handler(end  => "eof", "self");
  13. }
  14.  
  15. my $p = HTML::Parser->new(api_version => 3,
  16.               start_h => [\&title_handler, "self"],
  17.               report_tags => ['title'],
  18.              );
  19. $p->parse_file(shift || die) || die $!;
  20. print "\n";
  21.  
  22.