boojeboy has asked for the wisdom of the Perl Monks concerning the following question:

Ok so I ran across this code in a job listing for Fonality:
#!/usr/bin/perl s; (?:SEEKING)?; PERLqny~%|fsyx%~tz&; ?$^X=~m.\w+$.:DEVELOPERS; s"$&"Ktsf"i; s^.^chr ord($&)-5^eg; $\=$/;print||" ;) "
Output: Fona If you add 'use strict;' it won't run... How can I begin to untangle this code?

Replies are listed 'Best First'.
Re: Obfusicated code
by kyle (Abbot) on Dec 15, 2007 at 20:32 UTC
Re: Obfusicated code
by poolpi (Hermit) on Dec 15, 2007 at 21:56 UTC
    In a first time you can simplify the obfuscated code like this :
    s//Ktsf/; # now $_ = 'Ktsf' s/./chr ord($&)-5/e; # $_ = 'Fona' $\=$/; # By default $/ is a newline # A newline is printed after the last print print # print $_ and a newline => "Fona\n"
    Second time :
    use strict; print map { chr ord($_) - 5 } ('K', 't', 's', 'f'); print "\n";
    Finaly :
    'K' ASCII code = 75
    'F' ASCII code = 70
    chr 70 eq 'F';)

    HTH,
    PooLPi
Re: Obfusicated code
by Anonymous Monk on Dec 15, 2007 at 22:25 UTC
    $ perl -le' print "1: $_"; s/(?:SEEKING)?/PERLqny~%|fsyx%~tz&/ ? $^X =~ /\w+$/ : DEVELOPERS; print "2: $_"; print "3: $&"; s/$&/Ktsf/i; print "4: $_"; s/./ chr ord( $& ) - 5 /eg; print "5: $_"; $\ = $/; print || " ;) " ' 1: 2: PERLqny~%|fsyx%~tz& 3: perl 4: Ktsfqny~%|fsyx%~tz& 5: Fonality wants you! Fonality wants you!