3 ms·
As someone who loves obfuscated Perl...thanks! These are some great tricks.
by nemo1618 14y ago
As someone who loves obfuscated Perl...thanks! These are some great tricks.
- hippich 14y agoFrom someone who loves Perl, please do not use it in production :) Although, it is really interesting find!
- hahainternet 14y agoVery few of these are really unsuitable for production. High preference and conditional operation operators are probably the ones I would be most shocked to see. The rest (especially goatse, venus and things like X-Wing) should be fairly intuitive from operator precedence.
- to3m 14y agoPart of the problem, if you want to call it that, is probably that people like to put spaces in their code. This leads them to see magic, when in fact they're just insufficiently practiced at scanning the code as the computer sees it.
- prakashk 14y agoWhile I generally agree that the discretion must be observed when working on production code, I don't think the author is advocating these to be of wide use. These are very useful when you play Perl Golf, and can be pretty powerful in the hands of an expert player (sadly, my dreams of becoming one has remained just that.) The author of this document was a regular in Perl Golf tournaments and also in the Fun With Perl mailing list, which was a precursor and launchpad for several of these tournaments. For those interested, here is a series of articles about "The Lighter Side of Perl Culture": http://www.perlmonks.org/?node_id=410774 http://www.perlmonks.org/?node_id=410774 See also, "Perlgolf History" at http://terje2.frox25.no-ip.org/perlgolf_history_070109.pdf http://terje2.frox25.no-ip.org/perlgolf_history_070109.pdf (not sure if this link is still alive.)
- kamaal 14y agoWhoa!!!!, thanks for that pdf. Who ever compiled it has just done an awesome job!
- prakashk 14y agoIf I remember correctly, that would be "mtve" [1] (who sometimes went by a slightly longer "mtveurope"). If I had to pick the top three all-time Perl golfers, he would be one of them. [1] http://www.perlmonks.com/index.pl?node_id=143426 http://www.perlmonks.com/index.pl?node_id=143426
- irahul 14y ago> From someone who loves Perl, please do not use it in production :) From another someone who has written fair amount of perl, some of them are simple idioms suitable for production use; rest are just an exercise in curiosity. The venus operator "0+ $input"(or `0 + $input` as I will write it) is an acceptable and recommended way to convert input to number(i.e if you know your your input is a valid number in string form). !! isn't unique to perl - I have used it in JS, C etc to convert a value to boolean. @{[ ]} is useful for logging, thought it does look difficult to grok in first look. Goatse is basically list assignment and then using it in scalar context; I won't do that but assigning to list is frequently done `my ($a, $b) = $input =~ /regex/`. =<>~ is just badly formatted `my ($a, $b) = <> =~ /regex/` will read fine to a perl programmer.