develooper Front page | perl.fwp | Postings from December 2001

RE: The Santa Claus Golf Apocalypse

Thread Previous | Thread Next
From:
BooK
Date:
December 5, 2001 00:48
Subject:
RE: The Santa Claus Golf Apocalypse
Message ID:
1007542098.3c0ddf52c5aac@imp.free.fr
En réponse à Brad Greenlee <brad@footle.org>:

> What's really stumping me is that there has to be a shorter solution
for
> wc.pl (mine is 23), but I haven't been able to get past the need for
> printf (at least, not for a shorter solution). Has anyone managed to do
> it
without it?

My wc.pl is 21, but uses printf. I tried many things to get rid of printf,
but all of them ended up being longer...

Here they are (the first ' ' marks the end of the command-line switches):
-n END{print$a,$/}BEGIN{$a='00'x5}++$a # 38
-n BEGIN{$a=$-x10}$a++;END{print$a,$/} # 38
-n INIT{$a=$-x10}$a++;END{print$a,$/}  # 37
-lp0 $_=y/\n//;$_=$-x(- y///c%10).$_   # 36
-lp0 $_=substr$-x9 .y/\n//,-10         # 30

These are the longuest I did. All my shorter ones use printf.

At first, I used $^W, which  also equals 0, but if you want it to take only
2 chars, it's not very printable/visible.

In fact, here are all the special vars that equal 0 when perl starts:
$^C, $^D, $^H, $^P, $^S, $^W, $%, $-, $?

-- 
 Philippe "BooK" Bruhat

 Eliminate a problem before it eliminates you!
                                    (Moral from Groo The Wanderer #65 (Epic))

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About