Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Simple CLI calculator based on Perl's eval()

by roho (Bishop)
on Mar 05, 2021 at 16:20 UTC ( [id://11129168]=note: print w/replies, xml ) Need Help??


in reply to Simple CLI calculator based on Perl's eval()

I've been using the following on Windows for years (I named it "pc.bat"). Note: For typing convenience I replace 'x' with '*' for multiplication and perform addition on two or more numbers by separating them with spaces. I do not enter spaces around operators ('*', '/', etc.).

Examples: pc 2x4 (Total = 8) pc 1 2 (Total = 3)

@echo off perl -MInteger -e "s/x/*/g for @ARGV;print qq(Total = ), eval join(qq( ++),@ARGV), qq(\n)" %*

"It's not how hard you work, it's how much you get done."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (1)
As of 2024-04-25 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found