Live data from Hacker News

Perl secret operators and constants

search.cpan.org

1–10 of 46 posts

Re: Perl secret operators and constants

#3
Perl seems like a great language for a lot of text processing jobs, but while its learning curve isn't too steep, it goes on forever. I will continue to use it for quick little projects like cleaning up excel files, but I don't think I could ever get into things like Perl golf.

Re: Perl secret operators and constants

#9
post #6

I once managed to get some obfuscated Perl into an official Red Hat document (as a subtle joke): https://access.redhat.com/documentation/en-US/Red_Hat_Enterp... (search for "simple perl").

I am not sure I would call this obfuscated. The only real confusing piece of that code is if the reader doesn't know that you can use most punctuation characters with s///g

Re: Perl secret operators and constants

#10
if nothing else, most of these operators have immense nicknames. Now I just need an excuse to involve a flaming x-wing in my code...

    Operator     Nickname                     Function
    ======================================================
    0+           Venus                        numification
    @{[ ]}       Babycart                     list interpolation
    !!           Bang bang                    boolean conversion
    }{           Eskimo greeting              END block for one-liners
    ~~           Inchworm                     scalar
    ~-           Inchworm on a stick          high-precedence decrement
    -~           Inchworm on a stick          high-precedence increment
    -+-          Space station                high-precedence numification
    =( )=        Goatse                       scalar / list context
    ==~       Flaming X-Wing               match input, assign captures
    ~~         Kite                         a single line of input
    > m ; Ornate double-bladed sword   multiline comment
    -=!   -=!!   Flathead                     conditional decrement
    +=!   +=!!   Phillips                     conditional increment
    x=!   x=!!   Pozidriv                     conditional reset to ''
    *=!   *=!!   Torx                         conditional reset to 0
    ,=>          Winking fat comma            non-stringifying fat comma
    ()x!!        Enterprise                   boolean list squash
    0+!!         Key to the truth             numeric boolean conversion
    ~~!!         Serpent of truth             numeric boolean conversion
    ||()         Abbott and Costello          remove false scalar from list
    //()         Leaning Abbott and Costello  remove undef from list
Post reply on HN