Ian Phillipps <[EMAIL PROTECTED]> writes:
> On Fri, 07 Dec 2001 at 10:36:50 +1100, [EMAIL PROTECTED] wrote:
>> This hole was one by Japhy with his first post in the opening
>> hours of the game.
>
>> Like hole 2, this proved very frustrating with all attempts
>> to improve on printf failing.
> Dead right :-)
>
>> --- Tim Ayers ------------------------ 21
>> #!/usr/bin/perl
>> printf"%010d\n",$.,<>
>
> Harumph. I remember something like this approach flitting through my
> mind, but, I thought, the $. would be evaluated before the <>, so it
> would be zero.
>
> Moral: try it!
>
> Hmm... why isn't it zero?
Because perl passes arguments by reference. So $. gets shoved on the
stack (as $.) and <> gets evaluated in an array context so that the
results can be shoved on the stack. So, when printf comes to read the
value of $. '<>' has already been evaluated.
--
Piers
"It is a truth universally acknowledged that a language in
possession of a rich syntax must be in need of a rewrite."
-- Jane Austen?