#!/usr/bin/perl
# script to find the hash keys of a token returned by HTML:tokeparser.
# for example
link 1
# returnes href and class.
use strict;
use warnings;
use HTML::Tokeparser;
use Data::Dumper;
my $stream = HTML::TokeParser->new("test.html")
|| die "couldn't read in HTML file: $! ";
$stream->get_tag("h1");
$stream->get_tag("ul");
while ( my $token = $stream->get_token ) {
if ( $token->[0] eq 'S' and $token->[1] eq 'a' )
{
# what is going on here? What am i dealing with?
print " $token->[2]\n ";
# print " $token->[2]{href}\n\n ";
# print Dumper "$token \n\n\n"
# set the reference to the hash to new hash %hash
# how do i dereference this?
my %hash = $token->[2];
# below wont work unless i feed it a hash
# my $key;
# foreach $key (keys %hash) {
# print "at $key we have $hash{$key}\n";
# }
}
}
####
test document
This is a test of HTML::Tokeparser