[OT] golf

Abigail abigail at abigail.be
Tue Mar 4 20:41:02 GMT 2008


On Tue, Mar 04, 2008 at 06:53:00PM +0000, Nicholas Clark wrote:
> OK, this is going to be one of those things that people try to claim gets
> Perl a reputation for line noise, but pedants should note that every
> character here other than the space is in the set of portable file names...
> 
> Anyway, is there a shorter way to write
> 
>     perl -0777lp015e0
> 
> ?
> 
> [What it does is quite cynically left as an exercise to the reader. :-)]


As far as I can tell, it removes all return characters. That can be done
with three fewer character:

    perl -pes-^M--g

(In the shell, you might want to enter ^M as ^V^M - but it's still one
character). It probably fails the test of using portable file names, due
to the ^M.


> I'm sure the approach was used in an obfuscated Perl contest winner, but I
> also have this memory that theirs was shorter.


I've used a similar trick to replace characters. For instance,
to replace \r with \n, one could do:

    perl -015pl12e1



Abigail


More information about the london.pm mailing list