Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Not what you'd expect

by ProgrammingAce (Sexton)
on Mar 09, 2002 at 14:19 UTC ( [id://150565]=obfuscated: print w/replies, xml ) Need Help??

It's fun to use obfu to work on your regex skills...

#!/usr/bin/perl use strict; $_= "Just Another Perl Hacker"; print /(.)n/; s/^([^ ]*) *([^ ]*)/$3 $3/; /\sH(.)(.)/; print $2;/(.)\1.(.)/; print $2,",";print $_;


        - Ace "Two programmers walk into a bar, the third ducks"

Replies are listed 'Best First'.
Solution: Not what you'd expect
by domm (Chaplain) on Mar 09, 2002 at 19:40 UTC
    OK, let's de-obfuscate...
    $_= "Just Another Perl Hacker";
    print /(.)n/;
    That's easey, set $_ to JAPH, and print the first char followed by an 'n', i.e. 'A'.

    s/^([^ ]*) *([^ ]*)/$3 $3/;
    Here you have two capturing parenthenses, but replace with $3, which is undef. So in fact you are removing something of $_. And what are you removing?
    ^([^ ]*)
    Thats, from the beginning of the string, everything that's not a space, until the next space, i.e. 'Just'.
     *([^ ]*)
    This is basically the same regex, removing the next word (i.e. 'Another')

    /\sH(.)(.)/;
    This is no replacement, but a match for the two characters following ' H', that is 'a' and 'c'.

    print $2;
    Print the second match, i.e. 'c'.

    /(.)\1.(.)/;
    Another match, the most tricky in this obuf (IMO).
    Reminder: \1 in a regex is basically the same as $1 outside, i.e. the value found in the first capturing parenthenses.
    So, this matches the first char followed by itself, and saves the char after the next in $2. AS you replaced the first two words with nothing, $_ now looks like (using _ instead of space for clarity) __Perl Hacker, so the regex matches

    __Perl Hacker
    and thus saves 'e' in $2;

    print $2,",";
    Which you print here, followed by a ','.

    print $_;
    Print $_ (BTW, just print would've been enough..), .i.e. ' Perl Hacker'

    Not that hard to de-obfuscate, the only thing that made me wonder what was going on was '\1' in one regex.

    --
    #!/usr/bin/perl -w just another perl hacker
    print+seek(DATA,$=*.3,@-)?~~<DATA>:$:__DATA__
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found