|
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
|
Glob in the JAPH
1 direct reply — Read more / Contribute
|
by Eily
on Jun 17, 2013 at 19:00
|
|
|
This morning, the weather was quite warm and sunny, so I decided to take my bike to go to work. I didn't bother looking what it would be like in the evening. So I ended up in front of my computer, waiting for the rain to stop falling long enough for me to come back home, because I hadn't thought about taking a jacket. To pass the time, I made this:
($R,$B)=(q, another,,q( Perl hacker,),$a=Just);$,
=$V;m;(.)\(\)?;;*V=$::{$1};$\=$V;BEGIN{$|;$_=\$::
{b};m;(.)\(\)?;;*V=$::{$1}}print @$_ for [$a,$b],
My favorite JAPHs are those where the printed text isn't already obvious in the code. So I could have added some encryption or something to this one, but I thought I should rather stick to one main concept (concept I stumbled upon by accident) and shape (quite literally) this script around it. I still used some other obfuscations here and there to prevent the whole script from being too obvious, and to make it fit in a rectangle.
It does not run under strict, and warnings may make it easier to understand.
|
My JAPH
No replies — Read more | Post response
|
by varnie
on Jun 17, 2013 at 12:23
|
|
|
Hi there.
Here's my JAPH:
#!/usr/bin/perl
use warnings;
use strict;
my$k='my$i=0;
foreach my $v
(-4,26,10,-4,
-104,-56, -61
,-79,-94,-127
,-152,-162, -
268,-245,-250
,-264,-298, -
403,-361,-399
,-429,-454, -
494,-516){$_[
$i++]+= $v; }
join"",map{chr
}@_;';foreach(
reverse(12..35)
){$k="sub{$k}->
(\@_, int map{(
int)x\$_}(1..$_
))"}print eval$k
Shrinked version:
#!/usr/bin/perl
use strict;
use warnings;
my$k='my$i=0;foreach my$v(-4,26,10,-4,-104,-56,-61,-79,-94,-127,-152,-
+162,-268,
-245,-250,-264,-298,-403,-361,-399,-429,-454,-494,-516){$_[$i++]+=$v}j
+oin"",map
{chr}@_;';foreach (reverse (12..35)){$k="sub{$k}->(\@_,int map{(int)x\
+$_}(1..$_
))"}print eval $k;
|
Pumping JAPH
1 direct reply — Read more / Contribute
|
by choroba
on May 13, 2013 at 11:03
|
|
|
$|--;for($/=1/10;$/<=1/2;$/+=50e-7){$\=qq/J,\r/;
substr$\,$/*length$\,$/-$/,$_,for split/(.{2})/,
q/ursetk caanho tlhreerP /;print'';}warn qq/\n/;
Update: Retitled.
|
Length of array in hash of arrays
1 direct reply — Read more / Contribute
|
by ambrus
on May 09, 2013 at 09:57
|
|
|
my %g = (
k => [8, 2, 10, 2, 1, 3],
l => [10, 7, 9, 0, 1]
);
I know I can access the first element in one of the arrays like $g{k}[0]. But how do I get the length of that array?
Answer
Just try using random sigils, some combination is bound to work. The following script eases this task: it quickly runs all combinations of random sigils and prints the code that gives the right answer.
use 5.014;
no warnings; # some non-sensical combination of sigils would give warn
+ings
use strict; # we want answers without symbolic references
my %g = (
k => [8, 2, 10, 2, 1, 3],
l => [10, 7, 9, 0, 1]
);
sub sigil_combination {
sprintf("%X", $_[0]) =~ y/0-9A-F/$@#%*~^\->(){}.,;/r;
}
for my $n0 (1..1e5) {
my $c = "length " . sigil_combination($n0) . "g{k}";
if (6 == eval $c) {
say "$c";
}
}
__END__
|
Fibonacci Sequence
2 direct replies — Read more / Contribute
|
by skunix
on Feb 27, 2013 at 00:59
|
|
|
$~=$^=1;s//1 1 /;_:$~^=$^ ^=$~^=$^;$_.=($~=$~+$^." ");($~<99)?goto _:print
|
Closure JAPH
No replies — Read more | Post response
|
by aitap
on Feb 06, 2013 at 13:46
|
|
|
Just thought that a sub returning itself would be a funny thing to write. Well, here it is, a dragon eating its own tail, even if it's not looking like the original one:
#!/usr/bin/perl
use warnings;
use strict;
my
($j,$
a,$p,$h);$
j=sub{print(
chr($p+=$a->[$
h++]));$j};;;$a
=[0, split
"[: \n]+",
q/43 -002:1
-084 065:13
0001 000005
-0012 -00003
000013 -82 00048
21:13:-6.00:-76:72
-007.:02:00008.00
:::-6.00:::013
-70:3::-70:.64
/];$p=0x4a
;;$h=0;
$j->()->()->()->()->()->()->()->()->()->()->()->()->()->()->()->()->()
+->()->()->()->()->()->()->()->();
|
PERL hackers bank! can you get into the safe
1 direct reply — Read more / Contribute
|
by perlaintdead
on Jan 10, 2013 at 00:04
|
|
|
#!/usr/bin/perl
print "Welcome to the Internation PERL Hackers Bank\n";
print "Pin: ";my$Pin
=<> ;my$fapper;chomp
$Pin;$Brian=crypt$Pin,
"";goto l;i:if($Brian
eq$fapper xor-!1){
print "successfull. you leet!";}else{print "you no leet yet."};
exit;f:w:n:n:n:nin:nnhz:ng:gh:l:Ls:b:w:;
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!!!!1;
!!!!!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!!!!!
+!!!!!1;
!!!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!!!
+!!!!!1;
!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!
+!!!!!1;
!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!
+!!!!!1;
!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!
+!!!!!1;
!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!
+!!!!!1;
!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!
+!!!!!1;
!!!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!!!
+!!!!!1;
!!!!!!!!!!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!000;!!!!!!!!!!!!!!!!!!!!!!!
+!!!!!1;
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!!!!1;
my@c;my@e=(
"E","g","k","n","K",
"s","w","R","a","B",
"v","S","a","C","g",
"a","O","g","s","a",
"8","f","A","s","A");
local@a;push(@a,sort
ord 80 );unshift(@a,
sort'c');sort@a;my$r
=!!defined$Pin ;1xor
1or 0;my$D=(not(not(
not(not(not(not(not(
not($#a)))))))));for
(++$D;delete$e[($r)]
;$#e==$e[$r]){$~;$ r
=$ r+$ D;::;}map{11;
1;$fapper=join undef,
${_},$fapper;()*8}@e;
goto i;I:I:I:I:I:I:I:
|
an ocean of perl creatures
No replies — Read more | Post response
|
by perlaintdead
on Jan 04, 2013 at 02:01
|
|
|
sub z{$i = pop;for($|=1;&i;1){
c:x:k: n:e:r:}
sub i{ foreach (
split( m!!, "just another perl hacker\n")){
unshift @I,$_ if ###############################
+####
!! !!not $_ eq undef
}}sub _ {$H_{ 'n'}=$int #########################
+########################
=+0;; return $H_{'n'};
sub __{ $_=~ m~(??{sub
s{pop}; &s($_ );})~;return#########################
+##########
(($&, 'just ','another',
'perl', 'hack er'));}}}BEGIN ####################
+######################
{&z(q~c~ );my@ g,%H_;$H_{'n'}=0;@m=__($_)and
unshift @g,$m [(&_&&&_&&$#_)] #################
+#########
foreach @I;map
{print unless
$_=~m/(\x0A|\x0D)/;}@g;};
|
new to obfu JAPH
1 direct reply — Read more / Contribute
|
by perlaintdead
on Jan 02, 2013 at 06:06
|
|
|
fairly new to obfu. but hears my 3rd attempt at it.
see "download code" link for proper formatting
$i= abs sqrt 1;$|=1;for(my @s;$grove=~m; ;;$i=+"\x31"){caller;$grove=c
+hr"\x$i".0}$o=1;$O=0;local@a =(
# NAME: U.S.S. perl hacker
# SPACE COMMANDER: perlaintdead
# MISSION: To gaurd and protect the logic of this code
1,1 .$O. 5+1,$o.$o. 6+1,31+1,114+1,115+1,
' ',96+1,1 .$O. 9+1,112+1,115+1,# # \ /-------------
1 .$O. 3+1,1 .$O.$O +1,113+1,31+1,111+1,# *** ** =====
+==\
1 .$O.$O+1,1 .$o. 3+1, 1 .$O. 7+1,31+1,1 .$O. 3+1,# *** *****==
+ ==-====-
96+1,98+1,1 .$O. 6+1,1 .$O.$O+1,113+1# / \#_____***____* * =====
+==/
#27,123,136,2,,63,25,24,45,2435,235,#
);map{push@s,chr}@a;my$R=(eval{1/(eval{0/0})})if shift@s;goto mi;;
mi:rand$a. cos$grove;
for($n=0;$n<5;++$n){uc "j";push@g,'8';}++$R+(eval{1**&x})until $R=$#g;
+--$R-1
;delete@s[(--$R)]; foreach(@s){s//o/
if$_=~m~q~;;;;;;;syswrite$~,$_}sub x{$six=+abs 1;$six=~m/$six/ while$&
+ lt abs sqrt 100;}
|
/r JAPH
1 direct reply — Read more / Contribute
|
by trizen
on Dec 29, 2012 at 03:41
|
|
|
print$/=~s~~r~r=~s~~e~r=~s~~k~r=~s~~c~r=~s~~a~r=~s~~h~r=~s~~ ~r=~s<>
~l~r=~s~~r~r=~s~~e~r=~s~~P~r=~s~~ ~r=~s~~r~r=~s~~e~r=~s~~h~r=~s~~t~r
=~s~~o~r=~s~~n~r=~s~~a~r=~s~~ ~r=~s~~t~r=~s~~s~r=~s~~u~r=~s~~J~r////
Bonus:
\&~=~'\(';print+s{\x42}{$"}r,for($`..-$`)[4889245,650731,2540044,8375064,1505137],$/;
|
|
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|