BooK wrote: > > En réponse à Piers Cawley <pdcawley@bofh.org.uk>: > > > Ian Phillipps <igp_list2@tesco.net> 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! first I thought `but of cource', a bit later I was a bit confused... :) more clear would be something like: <>;printf"%010d\n",$. which does not work?! as I see it this is void context, but seems like I'm wrong 'cos it takes away one line... well list context can be forced: @_=<>;printf"%010d\n",$. I don't know why I did something like printf"%010d\n",$_=@_=<> which is the same :) > > > > > > 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","$.",<> P! Vladi. -- Vladi Belperchinov-Shabanski <cade@biscom.net> <cade@datamax.bg> Personal home page at http://www.biscom.net/~cade DataMax Ltd. http://www.datamax.bg Too many hopes and dreams won't see the light...Thread Previous | Thread Next