in reply to (jeffa) Re: Why doens't non-greediness work?
in thread Why doesn't non-greediness work?

For the parser types among us, there are likely more suitable options to be had though.
use strict; use warnings; use HTML::TokeParser::Simple; my %xlat = ( Smiley => ':)', Wink => ';)', ); my $p = HTML::TokeParser::Simple->new( \*DATA ); while ( my $t = $p->get_token ) { if( $t->is_start_tag('img') and my $r = $xlat{$t->return_attr->{alt}} ) { print $r; } else { print $t->as_is; } } __END__ <body> <a href="wink.html"> <img border="0" src="/images/wink.gif" alt="Wink"> </a> <a href="smile.html"> <img border="0" src="/images/smiley.gif" alt="Smiley"> </a> </body>
Note this doesn't require XHTML.

Makeshifts last the longest.