Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Help with simple calculator script.

by monktim (Friar)
on Oct 24, 2003 at 16:14 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-03-28 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found