in reply to Re: Re: How does ~~ force string interpolation of code into scalar context?
in thread How does ~~ force string interpolation of code into scalar context?

Perhaps you mean something other than I do?

If I had to guess — and I do — I think he does mean something different than you do. I understand the points both of you are trying to make.

Your two examples "work differently" only because you are, in reality, providing different data and interpretting the answer differently. It'll come as no surprise to you that they work the same if you make other things equal...

print ~"3"; print pack("c",~ord("3")); # Or... print ~3 print unpack("L", ~"\x00\x00\x00\x03");
and I think that's pg's point.

Your point, however, is really that Perl does treat strings and integers differently. And it's a good point. Another example that clears things up a bit:

$x = "3"; print ~$x; # This is... $x = 3; print ~$x; # Not the same as this... $x .= ""; print ~$x; # But, after stringification, it is.
So, you're both right. :-)

-sauoq
"My two cents aren't worth a dime.";