这个极其丑陋(但不知何故秘密美丽)的 Perl 代码有什么作用?

What does this horribly ugly (yet somehow secretly beautiful) Perl code do?

我在关于 Perl 脚本的 Powerpoint 演示文稿中找到了这段代码,它位于一个页面上,演示了如果您真的想那样做,Perl 代码会变得多么丑陋。该演示文稿没有说明此代码的作用。老实说,我非常想知道...它没有编译错误,所以它看起来是一个有效的 Perl 脚本,但我终究无法弄清楚它的作用。

这是脚本:

$_='while(read+STDIN,$_,2048){$a=29;$b=73;$c=142;$t=255;@t=map{$_%16or$t^=$c^=(
$m=(11,10,116,100,11,122,20,100)[$_/16%8])&110;$t^=(72,@z=(64,72,$a^=12*($_%16
-2?0:$m&17)),$b^=$_%64?12:0,@z)[$_%8]}(16..271);if((@a=unx"C*",$_)[20]&48){$h
=5;$_=unxb24,join"",@b=map{xB8,unxb8,chr($_^$a[--$h+84])}@ARGV;s/...$/1$&/;$
d=unxV,xb25,$_;$e=256|(ord$b[4])<<9|ord$b[3];$d=$d>>8^($f=$t&($d>>12^$d>>4^
$d^$d/8))<<17,$e=$e>>8^($t&($g=($q=$e>>14&7^$e)^$q*8^$q<<6))<<9,$_=$t[$_]^
(($h>>=8)+=$f+(~$g&$t))for@a[128..$#a]}print+x"C*",@a}';s/x/pack+/g;eval

我尝试了几次重新格式化它以尝试理解它,但我认为需要真正的 Perl 专家才能解决这个问题...

重新格式化的代码:

$_ = 'while(read+STDIN, $_, 2048) {
    $a = 29;
    $b = 73;
    $c = 142;
    $t = 255;

    @t = map {
        $_%16 or $t ^= $c ^= ($m = (11, 10, 116, 100, 11, 122, 20, 100) [$_/16%8])&110;
        $t ^= (72, @z = (64, 72, $a ^= 12*($_%16 - 2 ? 0 : $m & 17)), $b ^= $_%64 ? 12: 0, @z) [$_%8]
    } (16..271);

    if ((@a = unx"C*", $_) [20]&48) {
        $h=5;

        $_ = unxb24, join "", @b = map {
            xB8, unxb8, chr ($_^$a [--$h + 84])
        } @ARGV;

        s/...$/1$&/;
        $d = unxV, xb25, $_;
        $e = 256 | (ord $b[4]) << 9 | ord $b[3];
        $d = $d
            >> 8^($f = $t&($d >> 12^$d >> 4^$d^$d/8))
            << 17, $e = $e >> 8^($t&($g = ($q = $e >> 14&7^$e)^$q*8^$q << 6))
            << 9, $_ = $t[$_]^(($h >>= 8) += $f + (~$g&$t)) for @a[128..$#a]
    }

    print+x"C*",@a
}';

s/x/pack+/g;
eval

当您 运行 代码时,它似乎只是不断地接受用户输入。我一直无法弄清楚如何让它做任何其他事情,或者它是否还能做任何其他事情。

最后的 print 语句让我相信有一些方法可以让它打印输出。

Also please don't tell me to migrate this to the codegolf website... Questions about how code functions are considered off topic for the codegolf site and are told to be redirected to Whosebug.

将代码传递给 Google returns this page 解释

qrpff is a Perl script created by Keith Winstein and Marc Horowitz of the MIT SIPB. It performs DeCSS in six or seven lines. The name itself is an encoding of "decss" in rot-13.

另见 qrpff explained