#!/usr/bin/perl -w use strict; use LWP::Simple; use HTML::TokeParser; my $url ="http://perlmonks.org/index.pl?node_id=110166"; my $rawHTML = get($url); # attempt to d/l the page to mem die "LWP::Simple messed up $!" unless ($rawHTML); my $tp; $tp = HTML::TokeParser->new(\$rawHTML) or die "WTF $tp gone bad: $!"; # And now -- a generic HTML::TokeParser loop while (my $token = $tp->get_token) { my $ttype = shift @{ $token }; print "TYPE : $ttype\n####\n"; printf( join( '', map { "$_:%s\n####\n" } 1..@{$token} ) , @{$token} ); print "####################################################\n\n"; } __END__ Which produces something like: TYPE : D #### 1: #### #################################################### TYPE : T #### 1: #### 2: #### #################################################### TYPE : C #### 1: #### #################################################### TYPE : T #### 1: #### 2: #### #################################################### TYPE : S #### 1:html #### 2:HASH(0x1afeee0) #### 3:ARRAY(0x1afeef8) #### 4: #### #################################################### TYPE : T #### 1: #### 2: #### ####################################################