in reply to Re: Perl Golf 101
in thread Perl Golf 101

Excellent tips! I'll have to incorporate those into my golfed obfu, though I shan't post an updated version because its format is quite well fixed with the existing number of characters it had prior to the application of some of the tips received since posting. Since the first round of feedback from this node, I've already cut down another ~60 characters, and with yours I'm sure I'll cut down quite a few as well (Update: around another 20 so far), as the original makes a fair amount of use of some of the idioms you're suggesting which can be golfed further.

I sort of hinted at postfixing for not requiring the parens of braces without stating it explicitly, along with order of precedence.

As far as builtin variables, while I know what $- and $= are (and default to), I don't have anything in my notes about special effects they have - just a note for $* making any numerical value assigned to it an implicit int (which gives me an idea... ;-)

I will more than likely incorporate some of your suggestions (and especially your explanations!) into my original post, with of course your permission (and proper attribution on my part).

$,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}

Replies are listed 'Best First'.
Re^3: Perl Golf 101
by whio (Sexton) on May 27, 2006 at 07:36 UTC
    As you point out, $* converts numerical values to int. $= is similar except that it converts everything to int. $- is the same as $= except it can't go negative, or higher than INT_MAX. ($= seems to be able to go up to UINT_MAX.)