http://www.perlmonks.org?node_id=301884


in reply to Help with simple calculator script.

Some Super Search digging in our code vaults gives:

HTH

Replies are listed 'Best First'.
Re: Re: Help with simple calculator script.
by sauoq (Abbot) on Oct 24, 2003 at 22:29 UTC

    The problem with Juerd's is that it offers no error checking. This one does:

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

    For example:

    $ perl -ple'$_=eval' 1/0
    vs.
    $ perl -ple'$_=eval||$@||0' 1/0 Illegal division by zero at (eval 1) line 2, <> line 1.

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