Reputation: 21241
I found this Perl program:
''=~('(?{'.(']])@+}'^'-/@._]').'"'.('/<[*-_<+>?}{>]@}+@}]])@+}@<[*-_<+>?}{>]@^'^'`^=_^<]_[[]+[/,]_/]-/@._]/^=_^<]_[[]+[/,|').',$/})')
It prints "Obfuscated Perl to print obfuscated Perl"
I want to know how it actually prints this.
Upvotes: 9
Views: 202
Reputation: 118605
It is making good use of the bitwise string XOR operator ^
.
']])@+}' ^ '-/@._]'
evaluates to print
,
'/<[*-_<+>?}{>]@}+@}]])@+}@<[*-_<+>?}{>]@^'
^ '`^=_^<]_[[]+[/,]_/]-/@._]/^=_^<]_[[]+[/,|'
evaluates to Obfuscated Perl to print obfuscated Perl"
and the whole program reduces to
$ perl -MO=Deparse ...
'' =~ m[(?{print "Obfuscated Perl to print obfuscated Perl",$/})];
... syntax OK
Related: Acme::EyeDrops
Upvotes: 10