#!/usr/bin/perl -s our ($v); ## -v = verbose use XML::DT; use warnings; use Data::Dumper; use strict; use utf8::all; my $pat = shift; my $longest=1; my $filename = shift; if($filename){ $longest = 0} else { $filename = $pat } my $lxpath = "---"; my %handler=( '-html' => 1, '-pcdata'=> sub { if ($longest){ return "" if ctxt(1) eq "title"; return "" if ctxt(1) eq "script"; return "" if ctxt(1) eq "style"; $c=trim($c); if(length($c) > $longest){ $longest = length($c); $lxpath=pp(); $lxpath .= "-- $c" if $v; } } elsif ($c =~ /$pat/is){ if($v){ $c=~ s/\s+/ /g; print pp(),"-- $c\n\n"; } else { return "" if ctxt(1) eq "title"; return "" if ctxt(1) eq "script"; print pp(),"\n"; } }}, ); dt($filename, %handler); if($longest){ print $lxpath,"\n" ; } sub pp{ my $r="html/body"; my @a= reverse(@dtattributes); for my $i (2..@dtcontext-2){ $r .= "\n/$dtcontext[$i]"; $r .= "[\@class='$a[$i]{class}']" if $a[$i]{class}; $r .= "[\@id='$a[$i]{id}']" if $a[$i]{id}; # $r =~ s/\]\[/, /; } "$r\n"; } sub trim{ my $a=shift; $a =~ s/\s+/ /gr; }