#!perl -sw open(F,$0);open(O,">$$.pl");print O while(<F>);close F;

Replies are listed 'Best First'.
Re: This is a little shorter
by Juerd (Abbot) on Jan 25, 2002 at 16:52 UTC
    $0 should not be trusted.

    But if it's just about being short, I'll try too:
    open F,$0;open O,">$$.pl";print O while <F>
    Or, cheating and even less secure:
    open O,">$$.pl";print O `cat $0`
    Cheating even more:
    `cp $0 $$.pl`
    The same, but secure (if cp can be trusted):
    exec'cp',$0,"$$.pl"

    2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$