in reply to Can someone please break this obfuscated code down for me

BrowserUK has given you the best general tip above. If you're still wondering how that string turns into that program, an editor with syntax highlighting can help. Here's a breakdown if you still need it.

If you add some white space, you'll see the line looks like:

'' =~ ( '(?{' . ( '+]).][' ^ '[/@@){' ) . '"' . ( '^@@;.|' ^ '?,,^@^' ) . ',$/})' )
So it's matching the empty string against some bizarre pattern. The pattern is built up from concatenating five pieces, three of which are constants:

The other two parts are wrapped in parentheses, and are the result of combining two strings with the exclusive-or operator (^, perlop for more info). Since the parts are constant, perl evaluates them at compile time. If you test it, you'll see that the first expression evaluates to print and the second to allen".

So now you see how Deparse got that string. If you haven't seen the ?{...} construct in Perl regular expressions, take a look at perlre. It allows you to execute code inside a regular expression. In this case it executes the code print "allen",$/.

QED. HTH. :-)

If you want to really get a handle on how the exclusive-or operates to generate the string, it's best to look at the bits-n-bytes level. Try running this little snippet to see.

my @s = ( '+', ']', ')', '.', ']', '[', '[', '/', '@', '@', ')', '{', ); for (my $i = 0; $i < 6; $i++) { my ($l, $r) = ($s[$i], $s[$i+6]); printf "%s %x ^ %s %x = %s %x\n", $l, ord $l, $r, ord $r, $l ^ $r, ord $l ^ ord $r; }

Replies are listed 'Best First'.
Re^2: Can someone please break this obfuscated code down for me
by Burak (Chaplain) on Aug 02, 2006 at 19:34 UTC
    Excellent explanation :) and the code is really interesting...