Feb 12, 2002, 4:41 AM
Post #4 of 8
Re: [RedRum] Will you fall into the trap?
[In reply to]
I saw this post and was curious. Rather than cheat, I thought
I would take a guess as to what happens in this and then test
my guess later. If I didn't do this, then no one will see the point
of your exercise.
So, here goes:
print (1 + 2) + 4;
In this, the (1 + 2) portion of this is the real arguments to the
print function. Therefore I believe that '3' should be printed to
STDOUT. Since you did not assign a variable to the return result,
$_ should have the value of the returned value from print(), which
if it printed is '1', plus '4', the sum of which is 5. So, if you print $_
next, it would be '5'.
Next, looking at your second example:
print (1 + 2) + (4 + 4 + (3 + 3));
I believe that '3' should be printed to STDOUT again and a print of
$_ would print 15, the sum of the return value '1' + 14.
Now, I will go test this.
Good example of how not to program.
print unpack"u*",pack "h*",$a,"\n\n";