#!/usr/bin/perl
open P,shift;%p=('>',sub{$p++},'<',sub{$p--},'+',sub{$p[$p]++},'-',
sub{$p[$p]--},'.',sub{print chr$p[$p]},',',sub{$p[$p]=ord getc},'['
,sub{&c} ,);sub p{ exists$p{$_[0]}&&&{$p{$_[0]}}}p getc P until eof
P; sub c{push@c,getc P until$c[@c-1]eq']';do{p$_ for@c}while$p[$p]}
Awesome! I'll give this to my GF tonight.
Oh, you mean that other BF!
Nice. You can make it a little bit shorter by not giving p any arguments, and by using ARGV:
#!/usr/bin/perl
$/=\1;%p=('>',sub{$p++},'<',sub{$p--},'+',sub{$p[$p]++},'-',sub{$p[
$p]--},'.',sub{print chr$p[$p]},',',sub{$p[$p]=ord<>},'[',sub{&c});
sub p{exists$p{$_}&&&{$p{$_}}}p while<>;sub c{push@c,<>.!1until$c[@
c-1]eq']';do{p for@c}while$p[$p]}
perlmonks.org content © perlmonks.org and gustavderdrache, ikegami, mtve, truedfx
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03