Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Help with simple calculator script.

by monktim (Friar)
on Oct 24, 2003 at 16:14 UTC ( #301883=note: print w/replies, xml ) Need Help??


in reply to Help with simple calculator script.

If it's a homework than maybe eval can't be used yet.

You just need to read in the operator (- *) just like you read in the Name. Then you can use if.

if ($operator eq '-') { $c = $a - $b; } elsif ($operator eq '*') { # * code here } else { $c = 'invalid operator'; }
Read about the if statement and comparison operatiors (eq == ne !=).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2022-12-09 23:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?