swiftone has asked for the wisdom of the Perl Monks concerning the following question:
I have the code:
where $token is an HTML::TokeParser token for a starting A tag that contains an HREF attribute (otherwise $change is not set)my $tag; if($change){ #contruct modified tag # Wow this is ugly $tag = '<'.$token->[1].' '.join(' ',map({"$_ = '".$token->[2]{$_}."' +"} keys(%{$token->[2]}))).'>'; } else { #output original tag # This is nice $tag = $token->[0] eq "T" ? $token->[1] : $token->[-1]; }
Outputting unchanged tags is so elegant (idiom relayed to me by ChemBoy), surely there's a nicer way to convert a token I modify back into HTML? Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Rebuilding changed tags with HTML::TokeParser
by Ovid (Cardinal) on Dec 13, 2002 at 23:37 UTC | |
|
Re: Rebuilding changed tags with HTML::TokeParser
by Ionizor (Pilgrim) on Dec 13, 2002 at 23:39 UTC |