[Israel.pm] Strange variables puzzle

Issac Goldstand margol at beamartyr.net
Thu Jan 3 02:24:14 PST 2008


No I actually didn't (this fragment was just my
"I'm-Not-Going-Crazy-Right?" diagnostic statements; after 3 hours of
boiling the bug down to this, I was probably thinking well inside of my
own little box, which was why I posted it in the first place), but you
hit it on the nose!  Great thinking, Yitachak.

  Other Yitzchak :)

Yitzchak Scott-Thoennes wrote:
> On Wed, January 2, 2008 1:01 pm, Issac Goldstand wrote:
>> 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)?
> 
> I'm guessing from your wording that you yourself solved the puzzle,
> and that using ->eq("$url") fixes the problem.
> 
> The eq method considers an object of different class to be not equal,
> even if it would have stringified the same, and apparently $url is
> some class other than URI::http.
> 
> 
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl



More information about the Perl mailing list