Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Need help shortening this

by Anonymous Monk
on Nov 15, 2003 at 16:33 UTC ( #307322=obfuscated: print w/ replies, xml ) Need Help??

sub b{my $a='push@{$_[0]},('.$_[2].join($_[1],(('(pop@{$_[0]}||1)')x$_ +[0])).$_[3 ].');';sub{eval $a};}$a0=b(1,"","","x2");$a1=b(2,"+");$a2=b(2,"*");$a3 +=b(0,""," 1");$a4=b(1,"","print chr");$s=[];$z='"!3!+"%"#*9):B"--11$2A);"-!$):)1 ++!-%")*%")* -*%"!##))*%2!2%"##))B)1!#"*"A$)",+B"$")*%"#)C*-1!3"-"%"#*A)1!1+,%"1*B' +;map{&${"a $_"}($s)}map{$f=ord(substr($z,$_,1))-33;($f%8,int($f/8))}(0..111);

Yeah... first time trying, can't figure out how to compress it any further yet. Perhaps if I'd designed a more efficient stack machine?

Comment on Need help shortening this
Download Code
Re: Need help shortening this
by tilly (Archbishop) on Nov 15, 2003 at 16:53 UTC
    What are you trying to do? For me &{""} does the same exact thing, which is probably not what you wanted. (Perl 5.8.0 here.)
Re: Need help shortening this
by jonadab (Parson) on Nov 15, 2003 at 23:27 UTC

    I get the following error on both ActivePerl 5.8.0 (WinMe) and Perl 5.6.0 (Linux Mandrake):

    Undefined subroutine &main:: called at tempfile.pl line 4.

    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
      there can't be any whitespace in $z. If you copy/paste, delete any such white space before running the code and that should work. If it doesn't then . . . i don't know :-(

      jynx

      I've got that too first, but then I removed all newlines, and it worked that way.

Re: Need help shortening this
by jynx (Priest) on Nov 18, 2003 at 21:18 UTC
    after a few hours work, this is the best that i can come up with that doesn't deviate from your original algorithm. It's shorter by some 50+ characters (but still 6 characters over an 80-character, 4-line sig), and i'm sure more could be done; i just don't see what at the moment...
    # This has been tested with perl 5.6.1 on Solaris 9 only @a=map{sub{my$a="push\@s,($_[2]".join($_[1],('(pop@s||1)')x$_[0])."$_[ +3])";sub{ eval$a}}->(@$_)}[1,'','','x2'],[2,'+'],[2,'*'],[0,'',1],[1,'','print c +hr'];&{$a [$_]}for map{($f=ord(substr'"!3!+"%"#*9):B"--11$2A);"-!$):)1+!-%")*%") +*-*%"!#'. '#))*%2!2%"##))B)1!#"*"A$)",+B"$")*%"#)C*-1!3"-"%"#*A)1!1+,%"1*B',$_,1 +)-33)%8,$ f/8}0..111
    anyone else?
    jynx
      print'JUST ANOTHER PERL HACKER'

      Ok, just kidding :) With no changing of language, neither with any diligence:

      @_=@{([1,'','','x2'],[2,'+'],[2,'*'],[0,'',1],[1,'','print chr'])[$_]} +,eval" push\@s,$_[2]".join($_[1],('(pop@s||1)')x$_[0])."$_[3]"for map{($f=ord +()-33) %8,$f/8}'"!3!+"%"#*9):B"--11$2A);"-!$):)1+!-%")*%")*-*%"!##))*%2!2%"## +))B)1! #"*"A$)",+B"$")*%"#)C*-1!3"-"%"#*A)1!1+,%"1*B'=~/./g

      ... unpack is juts crying for this.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-07-12 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (240 votes), past polls