[OT] golf

Nicholas Clark nick at ccl4.org
Tue Mar 4 23:53:04 GMT 2008


On Tue, Mar 04, 2008 at 11:03:59PM +0100, Abigail wrote:

> No, Nick's code is correct. It's short for
> 
>    perl -0777 -l -p -015 -e 0
> 
> 
> The first -0 sets $\, the second sets $/.

It's much easier to see like this:

$ perl -MO=Deparse -0777lp015e0 
BEGIN { $/ = "\r"; $\ = ""; }
LINE: while (defined($_ = <ARGV>)) {
    chomp $_;
    '???';
}
continue {
    print $_;
}
-e syntax OK
$

Maybe we should call '???' the "Step 2" operator. As in:

$ perl -MO=Deparse -e 'do {steal_underpants(); "Step 2"; } until profit()'
do {
    steal_underpants();
    '???'
} until profit();
-e syntax OK
$

Nicholas Clark


More information about the london.pm mailing list