En r�ponse � Piers Cawley <[EMAIL PROTECTED]>:

> Ian Phillipps <[EMAIL PROTECTED]> writes:
> >> --- 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.

So I guess

#!/usr/bin/perl
printf"%010d\n","$.",<>

would print 0000000000 whatever the file. Doing what Ian thought it would do.

-- 
 Philippe BRUHAT - BooK

 When you run from your problem, you make it that much harder for good
 fortune to catch you, as well.     (Moral from Groo The Wanderer #14 (Epic))

Reply via email to