How do define subroutines for tags?

Calle Aasman (md4calle@mdstud.chalmers.se)
Thu, 19 Jun 1997 15:50:22 +0200 (MET DST)


Hi, I'm pretty sure this is a question asked pretty often, but I've tried
to find any examples but havn't find any...

What I want:

I would like to define sub routines for comments (<!--) and the script-tag
(<script)), How do I do this? And how do I do to make sub routines run for
tags that are unknown, e.g. to make a sub routine run for a
<asdfghjkl>-tag or something like that.

I've included the code I've written to redfine sub routines, but I don't
know how to add new ones.

all best,

/Calle

**************************************************************************
*         *         My homepage about the author Tom Holt:               *
*        /_\        http://www.mdstud.chalmers.se/~md4calle/holt/        *
*     { ~._.~ }                                                          *
*      (  Y  )      other things like OnLine Guitar Archive linkpage     *
*     ( )~*~( )     and heaps of musiclinks can be found at              *
*     (__)-(__)     http://www.mdstud.chalmers.se/~md4calle/             *
**************************************************************************

#!/usr/local/bin/perl
package FormatXX;
require HTML::Formatter;
@ISA=qw(HTML::Formatter);
 
sub new {
    my $class = shift;
    bless {}, $class;
}
 
sub img_start
{ 
    print "tobak";    
#    $tobak = "reine";
    #shift->out(shift->attr('alt') || "[image]");
}
sub h1_start {
    #shift->out("[MECK2000]");
    print "Header detected";
   
}

sub out {
    my ($self, $text) = @_;
    #print "$text";
    $meck=$meck.$text;
}
 

package main;
use HTML::Parse;
my $html = parse_htmlfile("frame.html");
my $form = new FormatXX;

print $form->format($html);
 
sub HTML::FormatText::table_start { 1; }