By folding the suggestions encountered so far, and adding in some of my own, I was able to bring the total down to 342 characters. Big gains can be made by observing that $foo[-2] refers to indices at the end of an array. That happens twice in this script.

In the part where the code pops to $_ and $0, it's cheaper to just call pop @n directly. This was the case with pop@n, and I guess it will still hold with p.

sub w as written contains a bug. Sometimes you push more than one element on. But that's okay, @_ is a win over $_[0].

I tried changing expr if cond to cond&&expr but that didn't do anything.

map{push@L,@C+0;push@C,lc=~/./g}<>;sub p{pop@n}sub w{push@n,@_}while($ +n<@C){$_= $C[$n++];if(/n/){$0=0;/-/ or$0=$_+$0*7while($_=index"htaoinse",$C[$n++ +])<7;w$0} if(/t/){$_=p;$_?$n=$L[$_-1]:last if p}/a/&&w 1+grep{$n>$_}@L;if(/h/){$ +_=p;w$n[- abs$_];$_>0&&splice@n,-1-$_,1}/o/&&print chr p;/s/&&w-p()+p;/e/&&w int + p()/p,p% p;w($_=getc)?ord:-1if/i/}

Note that changing /s/&&v-(p)+p to /s/&&v+p-p breaks the interpreter. Or at least, the hello.eta program no longer runs correctly, which was the extent of my testing. The interpreter is quite slow.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

In reply to Re: Is Perl less compact than Ruby? (Kind of competition) by grinder
in thread Is Perl less compact than Ruby? (Kind of competition) by locked_user mtve

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.