[Israel.pm] Strange variables puzzle

Issac Goldstand margol at beamartyr.net
Wed Jan 2 13:01:18 PST 2008


I've run into an interesting puzzle.  The following code fragment:

print "Ensuring that $url is in website ".$req->{baseurl}."...\n" if
DEBUG >=2;
print "OK1\n" if $url eq "http://jigsaw.w3.org/css-validator/";
print "OK2\n" if $req->{baseurl} eq "http://www.mirimar.net";
if
(URI->new("http://jigsaw.w3.org/css-validator/")->rel("http://www.mirimar.net")->eq("http://jigsaw.w3.org/css-validator/"))
{print "BAD";} else {print "GOOD";}
if (URI->new($url)->rel($req->{baseurl})->eq($url)) {print "BAD";} else
{print "GOOD";}

This has somehow managed to produce the following output:
Ensuring that http://jigsaw.w3.org/css-validator/ is in website
http://www.mirimar.net...
OK1
OK2
BADGOOD

Without any additional context can someone figure out how this *could*
be possible (the URI functions are from the standard URI module, $url
and $req->{baseurl} are passed in from another context which I can't
change, DEBUG is 2)?

  Yitzchak



More information about the Perl mailing list