Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

A peg-legged brainf*ck'd japh

by one4k4 (Hermit)
on May 27, 2003 at 19:02 UTC ( [id://261088]=obfuscated: print w/replies, xml ) Need Help??

I decided to send myself to hell and write a little obfuscated code for the lunch break.. That turned into "Lets learn more about map" which reminded me that I had the urge to write a half-finished (because that's the way everything is done in the corporate world, no?) BrainF*ck interpreter too. So, the JAPH below, albeit easy, was simply fun to create.
#!/usr/bin/perl -w use strict;sub bf {shift;my $i=0;my @v; map{$v[$i]+=m/\+/?1:m/-/?-1:0;print chr $v[$i] if(m/\./);}split(//);}my $eval=' sub japh{return $$?":":":"}';my $i = 'm y $i=0;';my @c = qw($_=" [0-9] ";$_=&ja ph;$$=&japh;s/:/+++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++ ++++++++++++.---------.+++++++++++++++. --------./g;&bf($_););map{$$.=$_}@c;$_= $$;s z[$c[1]|]z;zg;eval$eval;eval;


One4k4 - perlmonks@poorheart.com (www.poorheart.com)

Replies are listed 'Best First'.
Re: A peg-legged brainf*ck'd japh
by cciulla (Friar) on May 27, 2003 at 19:43 UTC

    I'd really love to ++ this one, as BF is truly sick and twisted, but I'm getting the following:

    Modification of a read-only value attempted at C:\japhs\one4k4.pl line 10.
    

    FWIW, I'm running ActiveState 5.8.0 on XP.

    Update: Trying to figure out why it won't work on 5.8...

    Update the Second: Apparently, 5.8 doesn't like it if you mess with $PROCESS_ID ($$)

      To reply to both comments above... I thought I was running 5.8, but I guess I wasn't.. /sigh. I suppose you could use any variable there, $a and just declare it earlier.. etc. Concept is still the same, although I do like the $$ variable for some reason.. I wonder if $^X is read only too. Thanks for the feedback!

      One4k4 - perlmonks@poorheart.com (www.poorheart.com)
Re: A peg-legged brainf*ck'd japh
by cfreak (Chaplain) on May 27, 2003 at 19:39 UTC

    Not bad. It fails with 5.8 though. (Didn't really take the time to find out why) 5.6.1 works fine.

    Just a side note, while learning about map you might want to make use of the fact that it returns an array. Though I suppose not returning from it makes it more obfuscated. :)

    Lobster Aliens Are attacking the world!
Re: A peg-legged brainf*ck'd japh
by stonecolddevin (Parson) on Jun 03, 2003 at 19:23 UTC
    That brainf*ck stuff is nuts!!!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-03-29 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found