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


by dsb (Chaplain)
on Feb 08, 2001 at 20:04 UTC ( #57194=obfuscated: print w/replies, xml ) Need Help??

Okay. I'm going a little JAPH happy. I like 'em though because they are helping me learn about new(to me) functions in Perl. Anyway, here's another, making use of the 'map' function which I keep seeing.
#/4a/75/73/74/20/41/6e/6f/74/68/65/72 open(FH,$0)||die;while(<FH>){chomp;if (m/^#(.*?)$/){$_=$1;@_=map {split'/'} $_;foreach(@_){print pack "H*", $_;}} }print "\n";########## kel ########## #/20/50/65/72/6c/20/48/61/63/6b/65/72
- kel -

Replies are listed 'Best First'.
Re: Japhaholic
by BooK (Curate) on Feb 09, 2001 at 15:40 UTC

    You call this obfuscation?

    You make not use of context, you explicitely use $_, @_, you never even try to hide something... It's so clear, you just read it and understand the whole thing!

    I showed it to a non-Perl programmer, explaining what split, etc did... I mean, we didn't even need to run the stuff to know what it did and how!

    Having all lines of the same length is not enough to qualify, in my view... Except if you lines are 4 characters long.

    Update: So that people stop downvoting me, here my shorter (but not more obfuscated) version:

    print+map{pack'H*' ,$_}('4a7573742041 6e6f74686572205065 726c204861636b6572 0a0d'=~m/(..)/g)

    It doesn't read its own source code, makes use of the fact that . doesn't match newlines, chains everything in one statement, etc...

      Tell me how you really feel why don't you. :) - kel -
Re: Japhaholic
by MrNobo1024 (Hermit) on Feb 09, 2001 at 21:05 UTC
    Here are a couple of tricks which might help you with your next JAPH:

    if you want to open your program's own source, instead of "open(FH,$0)" you can just use "open+0", and then you can use <0> to read lines.

    Instead of using \n for newlines use the variable $/ which is automatically set to a newline when your program starts

Re: Japhaholic
by Elgon (Curate) on Feb 09, 2001 at 00:10 UTC
    I write JAPHs for this reason also, however reading them is seriously good for your Perl knowlege - although I've never been tempted to use some of the more twisted mechanisms myself ;-)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://57194]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2018-06-25 00:48 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.