in reply to Re: Re: Small Calculator!
in thread Small Calculator!

Adding some error checking...

perl -ple'$_=eval||$@'

A calculator really should be able to tell you not to divide by 0, don't you agree? :-)

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Re: Re: Small Calculator!
by John M. Dlugosz (Monsignor) on Oct 07, 2002 at 14:48 UTC
    What if the result really is "false", e.g. zero?

      Ouch. Right. That would probably be more important than error checking. How about:

      perl -ple'$_=eval||$@||0'
      -sauoq
      "My two cents aren't worth a dime.";
      
        Cool--I'll have to remember that.