Just another Perl hacker: Difference between revisions
Appearance
Content deleted Content added
Geysirhead (talk | contribs) removed Category:Obfuscation; added Category:Software obfuscation using HotCat |
Thumperward (talk | contribs) per spedy Tags: New redirect Reverted |
||
Line 1: | Line 1: | ||
#REDIRECT [[Perl#Community]] |
|||
{{short description|Frivolous Perl program}} |
|||
{{multiple issues| |
|||
{{notablity|date=December 2021}} |
|||
{{Self-published|date=April 2020}} |
|||
}} |
|||
'''Just another Perl hacker''', or '''JAPH''', typically refers to a [[Perl]] program that prints "Just another Perl hacker," (the comma is canonical but is occasionally omitted). Short JAPH programs are often used as [[signature block|signatures]] in online [[Internet forum|forums]], or as [[T-shirt]] designs. The phrase or acronym is also occasionally used (without [[Computer programming|code]]) for a signature. |
|||
JAPH programs are classically done using extremely [[obfuscated code|obfuscated]] methods, in the spirit of the [[International Obfuscated C Code Contest|Obfuscated C Contest]]. More recently, as the phenomenon has become well-known, the phrase is sometimes used in ordinary examples (without obfuscation). |
|||
The idea of using tiny Perl programs that print a signature ''as a signature'' was originated by [[Randal L. Schwartz]], in his postings to the [[newsgroup]] comp.lang.perl.<ref>Randal L. Schwartz in [[Usenet]] message [email protected] explaining the origin of JAPH. Available through [http://groups.google.com/group/comp.lang.perl.misc/msg/ecc405feeefc120c Google.com]</ref> He wrote many of the JAPHs which are shown below. |
|||
==Examples== |
|||
JAPH program without obfuscation: |
|||
<syntaxhighlight lang="perl"> |
|||
print "Just another Perl hacker,"; |
|||
</syntaxhighlight> |
|||
Embedding JAPH in opaque code: |
|||
<syntaxhighlight lang="perl"> |
|||
$_='987;s/^(\d+)/$1-1/e;$1?eval:print"Just another Perl hacker,"';eval; |
|||
</syntaxhighlight> |
|||
Decoding JAPH from a transposed [[string literal]]: |
|||
<syntaxhighlight lang="perl"> |
|||
$_="krJhruaesrltre c a cnP,ohet";$_.=$1,print$2while s/(..)(.)//; |
|||
</syntaxhighlight> |
|||
Printing out JAPH as separate processes: |
|||
<syntaxhighlight lang="perl"> |
|||
for $i (0..4) { |
|||
if (!fork) { |
|||
$i == 0 or not { $SIG{INT} = sub { print "J" } } or |
|||
$i == 1 or not { $SIG{INT} = sub { print "A" } } or |
|||
$i == 2 or not { $SIG{INT} = sub { print "P" } } or |
|||
$i == 3 or not { $SIG{INT} = sub { print "H" } } ; |
|||
sleep $i; |
|||
last; |
|||
} |
|||
} |
|||
kill INT => $$; |
|||
</syntaxhighlight> |
|||
Appearing as if it does something completely unrelated to printing JAPH: |
|||
<syntaxhighlight lang="perl"> |
|||
$_ = "wftedskaebjgdpjgidbsmnjgc"; |
|||
tr/a-z/oh, turtleneck Phrase Jar!/; print; |
|||
</syntaxhighlight> |
|||
Forking processes to print out one letter each in the correct order:<ref>[http://perl.plover.com/obfuscated/ Plover.com]</ref> |
|||
<syntaxhighlight lang="perl"> |
|||
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{ |
|||
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord |
|||
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&& |
|||
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print |
|||
</syntaxhighlight> |
|||
Using only Perl [[Keyword (computer programming)|keywords]] (no [[punctuation]]):<ref>Originally posted at [http://www.perlmonks.org/?node_id=290607 perlmonks.org] by user blokhead</ref> |
|||
<syntaxhighlight lang="perl6"> |
|||
not exp log srand xor s qq qx xor |
|||
s x x length uc ord and print chr |
|||
ord for qw q join use sub tied qx |
|||
xor eval xor print qq q q xor int |
|||
eval lc q m cos and print chr ord |
|||
for qw y abs ne open tied hex exp |
|||
ref y m xor scalar srand print qq |
|||
q q xor int eval lc qq y sqrt cos |
|||
and print chr ord for qw x printf |
|||
each return local x y or print qq |
|||
s s and eval q s undef or oct xor |
|||
time xor ref print chr int ord lc |
|||
foreach qw y hex alarm chdir kill |
|||
exec return y s gt sin sort split |
|||
</syntaxhighlight> |
|||
Using only [[punctuation]], no [[alphanumeric]] characters. This breaks after Perl 5.30.0, as using $# and $* create fatal errors. This JAPH was written by [https://metacpan.org/author/ROODE Eric Roode] and only works on [[Unix]] and [[Unix-like]] systems: |
|||
<syntaxhighlight lang="perl"> |
|||
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=( |
|||
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++; |
|||
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++ |
|||
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=` |
|||
</syntaxhighlight> |
|||
A much shorter one, using only punctuation, based on the [https://metacpan.org/module/Acme::EyeDrops EyeDrops] module: |
|||
<syntaxhighlight lang="perl"> |
|||
''=~('(?{'.('-)@.)@_*([]@!@/)(@)@-@),@(@@+@)' |
|||
^'][)@]`}`]()`@.@]@%[`}%[@`@!#@%[').',"})') |
|||
</syntaxhighlight> |
|||
[[ASCII art]] (to make this [[dromedary]]-shaped code work, the console size needs to be set to at least 119×48):<ref>Originally posted at [http://www.perlmonks.org/?node_id=528042 perlmonks.org] by user liverpole.</ref> |
|||
<syntaxhighlight lang="perl"> |
|||
# |
|||
sub j(\$){($ |
|||
P,$V)= @_;while($$P=~s:^ |
|||
([()])::x){ $V+=('('eq$1)?-32:31 |
|||
}$V+=ord( substr( $$P,0,1,""))-74} sub a{ |
|||
my($I,$K,$ J,$L)=@_ ;$I=int($I*$M/$Z);$K=int( |
|||
$K*$M/$Z);$J=int($J*$M /$Z);$L=int($L*$M/$Z); $G=$ |
|||
J-$I;$F=$L-$K;$E=(abs($ G)>=abs($F))?$G:$F;($E<0) and($ |
|||
I,$K)=($J,$L);$E||=.01 ;for($i=0;$i<=abs$E;$i++ ){ $D->{$K |
|||
+int($i*$F/$E) }->{$I+int($i*$G/$E)}=1}}sub p{$D={};$ |
|||
Z=$z||.01;map{ $H=$_;$I=$N=j$H;$K=$O=j$H;while($H){$q=ord |
|||
substr($H,0,1,"" );if(42==$q){$J=j$H;$L=j$H}else{$q-=43;$L =$q |
|||
%9;$J=($q-$L)/9;$L=$q-9*$J-4;$J-=4}$J+=$I;$L+=$K;a($I,$K,$J,$ L); |
|||
($I,$K)=($J,$L)}a($I,$K,$N,$O)}@_;my$T;map{$y=$_;map{ $T.=$D->{$y} |
|||
->{$_}?$\:' '}(-59..59);$T.="\n"}(-23..23);print"\e[H$T"}$w= eval{ |
|||
require Win32::Console::ANSI};$b=$w?'1;7;':"";($j,$u,$s,$t,$a,$n,$o |
|||
,$h,$c,$k,$p,$e,$r,$l,$C)=split/}/,'Tw*JSK8IAg*PJ[*J@wR}*JR]*QJ[*J'. |
|||
'BA*JQK8I*JC}KUz]BAIJT]*QJ[R?-R[e]\RI'.'}Tn*JQ]wRAI*JDnR8QAU}wT8KT'. |
|||
']n*JEI*EJR*QJ]*JR*DJ@IQ[}*JSe*JD[n]*JPe*'.'JBI/KI}T8@?PcdnfgVCBRcP'. |
|||
'?ABKV]]}*JWe*JD[n]*JPe*JC?8B*JE};Vq*OJQ/IP['.'wQ}*JWeOe{n*EERk8;'. |
|||
'J*JC}/U*OJd[OI@*BJ*JXn*J>w]U}CWq*OJc8KJ?O[e]U/T*QJP?}*JSe*JCnTe'. |
|||
'QIAKJR}*JV]wRAI*J?}T]*RJcJI[\]3;U]Uq*PM[wV]W]WCT*DM*SJ'. 'ZP[Z'. |
|||
'PZa[\]UKVgogK9K*QJ[\]n[RI@*EH@IddR[Q[]T]T]T3o[dk*JE'. '[Z\U'. |
|||
'{T]*JPKTKK]*OJ[QIO[PIQIO[[gUKU\k*JE+J+J5R5AI*EJ00'. 'BCB*'. |
|||
'DMKKJIR[Q+*EJ0*EK';sub h{$\ = qw(% & @ x)[int rand |
|||
4];map{printf "\e[$b;%dm",int(rand 6)+101-60* ($w |
|||
||0);system( "cls")if$w ;($A,$S)= ($_[1], $ |
|||
_[0]);($M, @,)= split '}';for( $z=256 |
|||
;$z>0; $z -=$S){$S*= $A;p @,} sleep$_ |
|||
[2];while ($_[3]&&($ z+=$ S) <=256){ |
|||
p@,}}("". "32}7D$j" ."}AG". "$u}OG" |
|||
."$s}WG" ."$t","" ."24}(" ."IJ$a" |
|||
."}1G$n" ."}CO$o" ."}GG$t" ."}QC" |
|||
."$h}" ."^G$e" ."})IG" ."$r", |
|||
"32}?" ."H$p}FG$e}QG$r". "}ZC" |
|||
."$l", "28}(LC" ."" ."". |
|||
"$h}:" ."J$a}EG". "$c" |
|||
."}M" ."C$k}ZG". "$e" |
|||
."}" ."dG$r","18" ."}(" |
|||
."D;" ."$C" )}{h(16 ,1,1,0 |
|||
);h(8, .98,0,0 );h(16 ,1,1,1) |
|||
;h(8.0 ,0.98,0, 1); redo}### |
|||
#written 060204 by |
|||
#liverpole @@@@@@@ |
|||
#@@@@@@@@@@@ |
|||
</syntaxhighlight> |
|||
==See also== |
|||
*[["Hello, World!" program]] |
|||
*[[Obfuscated Perl Contest]] |
|||
*[[Perl#Perl pastimes|Perl golf]] |
|||
==References== |
|||
{{Reflist}} |
|||
== Further reading == |
|||
* {{cite book|pages=[https://archive.org/details/advancedperlprog00coze/page/n276 261]–263|title=Advanced Perl Programming|url=https://archive.org/details/advancedperlprog00coze|url-access=limited|author=Simon Cozens|publisher=O'Reilly|year=2005|isbn=9780596004569}} |
|||
==External links== |
|||
* [https://web.archive.org/web/20041209175230/http://www-106.ibm.com/developerworks/linux/library/l-japh.html Cultured Perl: The Elegance of JAPH] |
|||
* [http://www.cpan.org/misc/japh Cpan.org], a collection of JAPHs at [[CPAN]]. |
|||
* [https://stackoverflow.com/q/14440594 How does this famous JAPh work?] and [http://www.perlmonks.org/?node_id=290607 Fun With Reserved Keywords] at Stack Overflow explain how blokhead's code works. |
|||
{{Perl}} |
|||
[[Category:Perl]] |
|||
[[Category:English phrases]] |
|||
[[Category:Software obfuscation]] |
|||
[[Category:Test items in computer languages]] |
|||
[[Category:Computer programming folklore]] |
Revision as of 21:36, 21 August 2023
Redirect to: