[plug] Perl programming using HTML::Parser

Cameron Patrick cameron at patrick.wattle.id.au
Mon Apr 28 15:38:40 WST 2003


On Mon, Apr 28, 2003 at 03:20:13PM +0800, David Buddrige wrote:
|      if ( "$tagname" == "html" )
|      {
| 	   print "its a html tag!\n";
|      }
|      elsif ( "$tagname" == "span" )
| 
[snip]
| When I run the program over the file rabbits.html, I get the following 
| output: 
| 
| tagname : html
| its a html tag!
| tagname : head
| its a html tag!

As a Perl hater, I can tell you that it's because Perl's == operator is
cheerfully attempting to parse both $tagname and "html" as integers,
failing miserably without bothering to tell you, and assuming in its
infinite wisdom that these strings are equal to zero.  Thus somewhere
inside Perl your if statement is boiled down to
	if (0 == 0)
which is always true and so it never gets past the first if statement.



More information about the plug mailing list