in reply to Why doesn't non-greediness work?
Update: Seriously beaten to the punch and the above answers are WAY better than mine. :)
Because the first sub is clobbering the second sub.
Check this out...
my $body = qq!<img border="0" src="/images/wink.gif" alt="Wink"> <img +border="0" src="/images/smiley.gif" alt="Smiley">!; print "Inital Value\t $body\n"; $body =~ s/<img(.+?)="Smiley">/:)/g; print "First Sub\t $body\n"; $body =~ s/<img(.+?)="Wink">/;)/g; print "Second Sub\t $body\n";
Translating the first sub, ala Friedl:
find <img followed by one or more characters repeated zero or one times followed by ="Smiley"
So, it's being TOO greedy!
Cē
|
|---|