Passes -w, but not strict. No error checking, but it works for the 4 major functions. 102 strokes, not counting the shebang line.
Is there a better (shorter) way to do the $y=o;$x=o; $x$1$y part? You have to do it in that order or else division and subtraction give the wrong result, but it seems like that could be condensed further.
#!/usr/bin/perl -w
sub p{push@s,shift}sub o{pop@s}for$n(@ARGV){if($n=~/(\D)/){$y=o;$x=o;p
+(eval"$x$1$y")}else{p$n}}print o
---
A fair fight is a sign of poor planning.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|