http://www.perlmonks.org?node_id=1597

Got some code which would take a Perl grand master to understand without running it? Post it in this section so we can stare at it in awe.

Word of warning, though: Don't be too cocky with your post — almost inevitably someone will post a reply that does the exact same thing in even fewer characters!

New Less than Readable Code
room 237 JAPH
No replies — Read more | Post response
by Discipulus
on Mar 08, 2019 at 08:02
    NB: minimum console width 108

    THE : OVERLOOK: MAZE: $} = pack ('H*' ,'416c6c20776f726b20616e64206e6f20706c6179206d616b6573204a61636b206120 +64756c6c20626f79' ## #### #### #### #### ####### #### ### +# #### #### ## );for((1,1,1,1,0)x 4,(0,2,4,6,8)x 4,(0,8,6,4,2) x 4,'ll',(1,1,1,1,0),' +\sand',(1,1,1,1,0 ## #### #### #### #### #### #### ### +# #### #### ## ),'\sno',(1,1,1,1,0),'\sp\Klay',(1,1,1,1,0),'\sdu',(1,1,1,1,0),'ll',(1 +,1,1,1,0),'a.boy' ## #### #### #### #### ####### #### #### #### + #### ## ,(1,1,1,1,0),(0,0,1,1,1,1,1)x 4,'\swork',(1,1,1,1,0),'\swith',(1,1,1,1 +,0),'\smakes',(1, 1,1,1,0)x 4,'a',(1,1,1,1,0),((join'|',split'','perl'),1,$",1)x 4,(1,1, +1,1,0)x 4,){ ($}= ## #### #### #### #### #### #### ### +# #### #### ## $}) =~ s/^(A)(.)(.)(.)$/ $3$1$2$4/ or$}=~/a boy/?($}=$})=~s/a\Kck/pH/: +'' or( ($X=$^X)=~ s/.*\W(.{4})\.?.{0,3}$/ucfirst($1)/e and($}=$})=~s/\bp\b/with $X/) or +print/\D/?($}=$}) ## #### #### #### #### #### ### +# #### #### ## # #### #### #### #### #### #### + #### # # #### #### # JAPH # + #### #### # # #### #### #### #### #### #### + #### # ## #### #### #### #### #### ### +# #### #### ## =~s/$_//&&sleep 1&&next:($_?$"x((80-length$} x 2)/2+$_):$/.$".$".$" x( +(80-length$} x 2) /2+$_)),$" x $_,$},$" x 5,$},$/;select undef,undef,undef,0.3;}print$/. +$/;for $_237(4,3, ## #### #### #### #### ####### #### #### #### + #### ## 2,1,1,1,0,0,0,0,0){$redroom =$} eq $redroom?' 237':$}; for(121118033,7 +7833563,77899093, 119840081,78947665,77899089,77899089,79406545,){print +(map{$_>0?$redr +oom:$".$".$".$"}( ## #### #### #### #### ####### #### ### +# #### #### ## split'',sprintf("%b", $_))),$/;select undef,undef,undef,0.3;print$/ x +$_237;}print$/.$/ ## #### #### #### #### #### #### ### +# #### #### ## .$/;select undef,undef,undef,1;}for(60649,21161,21161,21161,24303,8666 +5,86665,119433,){ ## #### #### #### #### ####### #### ### +# #### #### ## print +(map{$_>0? $redroom:$".$".$".$"}(split'',sprintf("%021b",$_))), +$/;}print $/ x 10

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
lost : in : keywords
No replies — Read more | Post response
by Discipulus
on Feb 24, 2019 at 06:32
    die:abs:accept:alarm:atan2:bind:binmode:join:bless:caller:chdir:chmod: chomp:chop:chown:chr:chroot:pos:print:printf:prototype:push:quotemeta: close:closedir:connect:cos:last:crypt:dbmclose:dbmopen:defined:delete: die:dump:each:endgrent:last:endhostent:endnetent:endprotoent:endpwent: endservent:eof:eval:exec:exists:exit:exp:extern:fc:fcntl:fileno:flock: fork:format:formline:getc:or:getgrent:getgrgid:getgrnam:gethostbyaddr: gethostbyname:and:gethostent:or:getlogin:getnetbyaddr:or:getnetbyname: getnetent:getpeername:last:getpgrp:getppid:getpriority:getprotobyname: getprotobynumber:getprotoent:getpwent:getpwnam:getpwuid:getservbyname: getservbyport:and:getservent:and:getsockname:or:getsockopt:given:glob: gmtime:and:goto:or:grep:hex:index:int:import:localtime:lock:log:lstat: map:mkdir:last:ioctl:join:keys:kill:last:lc:lcfirst:length:local:link: or:listen:msgctl:msgget:or:msgrcv:msgsnd:my:next:not:oct:open:opendir: ord:our:or:pack:or:pipe:pop:pos:print:printf:prototype:push:quotemeta: rand:read:and:readdir:readline:and:or:readlink:readpipe:recv:redo:ref: rename:require:reset:return:reverse:rewinddir:rindex:rmdir:say:scalar: seek:last:seekdir:select:semctl:semget:semop:send:setgrent:sethostent: setnetent:and:setpgrp:or:setpriority:or:setprotoent:setpwent:shutdown: and:shmread:shmwrite:setservent:or:setsockopt:and:shift:shmctl:shmget: or:sin:sleep:socket:and:socketpair:and:sort:splice:split:sprintf:sqrt: srand:stat:state:study:substr:symlink:syscall:sysopen:sysread:sysseek: system:syswrite:tell:or:telldir:tie:tied:time:times:truncate:uc:undef: and:unimport:unpack:unshift:untie:use:or:utime:values:vec:wait:unlink: or:ucfirst:umask:waitpid:wantarray:warn:when:or:whereis:whereso:write: seek DATA,0,0and print+uc(substr<DATA>,40,1)and print+(uc substr<DATA> ,68,1)and(print+uc(substr<DATA>,51,1))and!print+(uc substr<DATA>,31,1) __DATA__:and:getservent:and:getsockname:or:getsockopt:given:glob:last: die:abs:accept:alarm:atan2:bind:binmode:join:bless:caller:chdir:chmod: chomp:chop:chown:chr:chroot:pos:print:printf:prototype:push:quotemeta: close:closedir:connect:cos:last:crypt:dbmclose:dbmopen:defined:delete: die:dump:each:endgrent:last:endhostent:endnetent:endprotoent:endpwent: endservent:eof:eval:exec:exists:exit:exp:extern:fc:fcntl:fileno:flock: fork:format:formline:getc:or:getgrent:getgrgid:getgrnam:gethostbyaddr: gethostbyname:and:gethostent:or:getlogin:getnetbyaddr:or:getnetbyname: getnetent:getpeername:last:getpgrp:getppid:getpriority:getprotobyname: getprotobynumber:getprotoent:getpwent:getpwnam:getpwuid:getservbyname: getservbyport:and:getservent:and:getsockname:or:getsockopt:given:glob: gmtime:and:goto:or:grep:hex:index:int:import:localtime:lock:log:lstat: map:mkdir:last:ioctl:join:keys:kill:last:lc:lcfirst:length:local:link: or:listen:msgctl:msgget:or:msgrcv:msgsnd:my:next:not:oct:open:opendir: ord:our:or:pack:or:pipe:pop:pos:print:printf:prototype:push:quotemeta: rand:read:and:readdir:readline:and:or:readlink:readpipe:recv:redo:ref: rename:require:reset:return:reverse:rewinddir:rindex:rmdir:say:scalar: seek:last:seekdir:select:semctl:semget:semop:send:setgrent:sethostent: setnetent:and:setpgrp:or:setpriority:or:setprotoent:setpwent:shutdown: and:shmread:shmwrite:setservent:or:setsockopt:and:shift:shmctl:shmget: or:sin:sleep:socket:and:socketpair:and:sort:splice:split:sprintf:sqrt: srand:stat:state:study:substr:symlink:syscall:sysopen:sysread:sysseek: system:syswrite:tell:or:telldir:tie:tied:time:times:truncate:uc:undef: and:unimport:unpack:unshift:untie:use:or:utime:values:vec:wait:unlink: or:ucfirst:umask:waitpid:wantarray:warn:when:or:whereis:whereso:write:

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
BEGIN X
1 direct reply — Read more / Contribute
by Discipulus
on Jan 31, 2019 at 16:24
    BEGIN{print','; BEGIN{print'r'; BEGIN{print'e'; BEGIN{print'k'; BEGIN{print'c'; BEGIN{print'a'; BEGIN{print'H'; BEGIN{print' '; BEGIN{print'l'; BEGIN{print'r'; BEGIN{print'e'; BEGIN{print'P'; BEGIN{print' ';BEGIN{print'r'; BEGIN{print'e'; BEGIN{print'h'; BEGIN{print't'; BEGIN{print'o'; BEGIN{print'n'; BEGIN{print'A'; BEGIN{print' '; BEGIN{print't'; BEGIN{print's'; BEGIN{print'u'; BEGIN{print'J'; BEGIN{print''; }}}}}}}}}}}}}; }}}}}}}}}}}}};

    Inspired by Assignment and use statement in the same BEGIN block and

    perl -e "$}.=qq(BEGIN{print qq($_);)for(q(,rekcaH lreP rehtonA tsuJ)=~/./g);$}.=q(})x25;eval$}"

    A little modification after having seen it under the morning light.

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
cOMPRESSed JaPH,
No replies — Read more | Post response
by kschwab
on Dec 30, 2018 at 13:55
    Run on a VT100 compatible terminal
    #!/usr/bin/perl BEGIN{$^="USE\0cOMPRESS\x1a\x1azLIB"^" ",$^=~s,$, $^,ee};$_=q|M'XL(`*[Q*%P"`Y5231J%(`C<=PJ.VJ)E"U?T\\ZSNYDD>(B)HF_P^R V9@A!A(MN"5<0!=]P[@831@,-!4@,\\(N"1%8[U%)BV[Y-,:12L?1&S.C5]A]F4+RES `)M=WN*$C4R#/YH[YT\\/>:$IY/?&(M#&>VATA0W9VBE7T-U<2LWU%.$ALFQ=J"\\M= ICPR"76N)ZYZS7P<7U/*.ZP!N$BHG,%-BZ,`E+WV@_7_N90.FH18I'@K*69M(LSP4X; :C=:)EP[H@MXNEWIO?[&'U@_#@,?:O54D([YD6E$_3F^+*NOL<Q1+4Y0[.M_SP=<;<Y O0'IR@8@`4$|;y| \n||d;$_=unpack'u';$,='-V4Jfdy{lzz33Se`k33dldN|gs'. '`y!-V 2y{`g}2';$,^="\t"x$,=~y,,,c;$,=~s;^;$,;ee;
Perl Golang Partial Polyglot
No replies — Read more | Post response
by kschwab
on Dec 30, 2018 at 09:50

    Similar to my earlier Perl Python Partial Polyglot.

    This one runs under either Golang (go run ./script) or Perl, and produces *mostly* the same output. Arguably not a true polyglot since the Go doesn't depend on the Perl, but the Perl certainly depends on the Go.

    //;$_=<<'/*',y'>>''; package main; func main() { print("Just another Golang Hacker,\n"); } //;main() /* s&(\146\w{3})(.*)\x47\w{5}&lc($1^'5 ,C').$2.('dQFX'^4x4)&es;s;$;$_;ee; */
More fun with a reference
1 direct reply — Read more / Contribute
by kschwab
on Dec 22, 2018 at 12:48
    Stealing part of choroba's idea.
    perl -e 's/^/pack+q.a..($^F^$^F**$^F),qq^\x19"\x11\x04mX^^\$\//e/print +'
Just Another Perl Hacker,
1 direct reply — Read more / Contribute
by choroba
on Dec 21, 2018 at 10:43
    Having fun with references.
    print map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[ +{}],[sub{}^*ARGV,3];

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
VT100 Screensaver
1 direct reply — Read more / Contribute
by kschwab
on Dec 09, 2018 at 16:27

    Only works on Unix like machines...requires a VT100 compatible terminal like an xterm, and a working "stty" binary. Handles resizing the window while it's running. Ctrl-C to stop it.

    #!/usr/bin/perl use warnings;use strict;my($r,$c);$|=1;init(); sub init{print "\ec";($r,$c)=split' ',qx"stty size";$r-=5;$c-=16}; $SIG{INT}= sub{print "\ec\n";exit};$SIG{WINCH}=sub{init()}; $_='!X!E!EIC%IC%IC%!X!ECu#kCD@3ilowg!E!WICD@biloQgIO#kAr@DiloT@/@j'. '@D@j@%IO#myD@gg!QCu#kC%IO#kO#gO#gC%!MIC%!QCu#kC%IO#ne#me#ni%!MICD'. '@f@/iloQK';s/!/4pa/g;s/@/ilp/g;s/#/KW/g;s/%/Ag/g;tr|A-Za-z0-9+/| -_|; @_=split(/\n/,unpack('u',join($',map(chr(32+length($_)*3/4). $_,/(.{1,60})/gs))));print "\ec\e[2J\e[?25l";srand(); for (;;) { my($x,$y)= map{int(rand($_))+1}($c,$r); for(0..4){print "\e[".($y+$_).";${x}H".$_[$_];} select($\,$\,$\,rand(1.2)+.3); for(0..4){print "\e[".($y+$_).";${x}H"." "x16;} }
Christmas Package Obfuscation
1 direct reply — Read more / Contribute
by kschwab
on Dec 08, 2018 at 14:11
    #!/usr/bin/perl $;;$^;s#^#$\ _-~,..___ .-' .--._ ```--.-----.___ ._^---- (`-...`-. _/,----. ) ````---=. _.-'' ````-- `.___.-.) (---=='' .-' | _.-' _.-. )(`.-._``--.._ .' | |`---..__ .-'.-'.' )| |_ ``--...`. | | ``--.._ ,'.-' ( ( `-.`-. .'| : | | | | --.._`. ) `. `. | : | | | | ( )-.._.') ) ) : | | | | | | | ( ( ) : | | | | (_( | ) ) | : .' | | | | L/ | : .' (__ | | | | :.' `-.._ | | | | : `-.._ | | | |/ `--`_|_ | .' `._ | .' ``-.__ | .' `--`; # and "Happy Holidays" or Merry Christmas! print "Is print broken?\n";print;# guess not?
perl: we package API -- oneliner
2 direct replies — Read more / Contribute
by Discipulus
on Dec 07, 2018 at 07:11
    perl -we "package API{$|++;$'__=__PACKAGE__;$\"=','}print/J$__/?exit:q +q($_\r)for glob qq{{@{[A..P,I]}}}x4"

    Note: Win32 double quotes!

    Thanks Tux, thanks Eily

    L*

    PS changed the title from empty API package -- oneliner to the current

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Set the new obfuscation standard
Title:
code@?#!:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":


  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.