Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Original Enough?

by perldeveloper (Scribe)
on Jul 01, 2004 at 11:55 UTC ( [id://371046]=obfuscated: print w/replies, xml ) Need Help??

@ARGV=$0; $GR=@AV+$=;$_=<>;s/([^+]+)\+.+/y|$+$GR++|morenlpsk|/;eval;s/[^k]+?kk(.+)kk.+/$+/;print;

Update: Prints `perlmonks'. Runs only from its own file, code starting on first line with no extra leading spaces, obviously no #!/usr/.../perl on the first line.

What it does
Transliterates the perl code itself onto the perlmonks string. Reuses an anagram of the same characters (@ARGV=$0; to $GR=@AV..) to generate more perl code and transforms it into a y||| transliteration by using an s/// search. Also uses the fact that unmapped transliteration characters are mapped to the last of the mapped-to characters. Obfuscates the character 0 (zero) by using the $= variable whose value is usually 60 by default (`6' will map to the last transliteration character, `k', while `0' will map to `s').

I see another monk, jdalbec, has taken the time to rearrange the code in a reply.

Replies are listed 'Best First'.
Re: Original Enough?
by jdalbec (Deacon) on Jul 02, 2004 at 03:31 UTC

    Use <code> tags to prevent line breaking at spaces.

    I've broken up the statements into separate lines where possible. You may want to uncomment the extra print statements I've added and run the modified program to get a better view of what's going on. Highlight the black table to view the code.

    @ARGV=$0; $GR=@AV+$=; # everything up to the + sign must be unchanged $_=<>; # read first (only) line of file s/([^+]+)\+.+/y|$+$GR++|morenlpsk|/; # replace entire line w/ translat +e # print; eval; # self-modifying code! # print; s/[^k]+?kk(.+)kk.+/$+/; # get rid of everything but the magic word(s) print$_;
Re: Original Enough?
by Anonymous Monk on Jul 08, 2004 at 21:35 UTC
    this is real cool. the thing i don't understand is, why $_=<> is reading the first line, not from STDIN. could you please give me a hint about this? thanks alot.
      The diamond operator <> attempts to read from the file denoted by the elements in @ARGV (it tries reading from $ARGV[0] and increases the index in case opening the file denoted by the previous index fails).

      An assignment of the form @ARGV=$0 is the same as @ARGV=($0), which actually means $ARGV[0]=$0. Since $0 is the filepath of the perl script itself, the diamond operator will read the first line from the perl script file.

      The diamond operator will read from STDIN only if the @ARGV list is empty.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://371046]
Approved by atcroft
Front-paged by muba
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-13 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found