Perl

  • 15th August 2018

Dots and Dashes

#!perl -p
y/.-/01/;s#\d+/?#substr'01etianmsurwdkgohvf,l.pjbxcyzq',31&oct b1.$&,1#ge

Perl is (in)famous for the ability to write programs that look like line noise, and today I will take apart this beautiful piece of code. Written by tybalt89, it can decode sequences of dots and dashes to Latin letters in just 73 characters of code…

Read more 
  • 13th March 2018

Anatomy of the heart

#!/usr/bin/perl -w
use strict;

     my$f=           $[;my
   $ch=0;sub       l{length}
 sub r{join"",   reverse split
("",$_[$[])}sub ss{substr($_[0]
,$_[1],$_[2])}sub be{$_=$_[0];p
 (ss($_,$f,1));$f+=l()/2;$f%=l 
  ();$f++if$ch%2;$ch++}my$q=r
   ("\ntfgpfdfal,thg?bngbj".    
    "naxfcixz");$_=$q; $q=~
      tr/f[a-z]/ [l-za-k] 
        /;my@ever=1..&l
          ;my$mine=$q
            ;sub p{
             print
              @_;
               }
                         
       be $mine for @ever 

This heart-shaped program is written in the language of choice for producing unreadable and obfuscated code: Perl 5. It also serves an unusual purpose of a proposal…

Read more 
  • 7th October 2017

Regex prime checker

This Java snippet uses a regular expression for something way different than they were designed for: a primality check.

public static boolean prime(int n) {
    return !new String(new char[n]).matches(".?|(..+?)\\1+");
}
Read more