Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: /^[^A-Za-z0-9 ]*$/

by deep submerge (Scribe)
on Sep 30, 2005 at 18:22 UTC ( #496483=note: print w/replies, xml ) Need Help??


in reply to /^[^A-Za-z0-9 ]*$/

Using Deparse just takes away all the magic, leaving me with a little to no understanding of how it works... =P

How do you translate from "noise" to alphanumeric characters?

Replies are listed 'Best First'.
Re^2: /^[^A-Za-z0-9 ]*$/
by Roger_B (Scribe) on Sep 30, 2005 at 20:47 UTC
    Yes, that amused me when I tried it. My clue about deparse was in case anyone's perl wasn't called 'perl' or wasn't on the path; the deparsed version shows that part of how it works.

    Here's a partially de-obfuscated version:

    $_ = ( '_[]@^' ^ '/>/,~' ) . # 'perl ' '-' . # '-' ( '>]' ^ '[}' ) . # 'e ' '"' . # '"' ( '^])@*{.|~%{{]\\-' ^ './@.^[}(:`))}-\\' ) . # 'print STDERR qq' '(' . # '(' ( '*\\(]{\\./(@[-^-%^,{(!]+>^' ^ '@)[)[=@@\\(>_~]@,@[@@>@[,' ) . # 'just another perl hacker' '\\' . # '\' ( '.' ^ '@' ) . # 'n' ')"'; # ')"' `$_`

    basically it's a concatenation of strings, using the bitwise xor operator '^' to generate alphanumeric characters, per chester's line noise JAPH. For example the 'p' in the first 'perl' comes by xoring '_' and '/':

    perl -e "print '_' ^ '/'" p

    Deparsing de-obfuscates it because the entire xoring and concatenation is made up of literals, so the compiler calculates the result and substitutes it into the compiled version. Deparse simply translates the compiled code back into Perl code. A simpler example might be:

    perl -MO=Deparse -e "print 2 * 2" print 4; -e syntax OK

    '2 * 2' is translated to '4' at compile time and deparse leaves it that way.

    HTH

    Roger

    P.S. blokhead pointed out to me that this too has been done before!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://496483]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2020-02-21 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (96 votes). Check out past polls.

    Notices?