#!usr/bin/perl
print "Enter a number.";
$number = <STDIN>;
# *ing by 2 (can't get to the right word)
$result = $number * 2;
print "Aye, the result is" . $result;
Which you could do some tests with.
Bob
From: "Jacques Lederer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: scalar number or string?
Date: Sun, 19 Jan 2003 18:44:31 +0100
Hello,
When you write
$calc=3+5-2;
print $calc."\n";
you get 6. (number, not the string "3+5-2")
When you write
while (<STDIN>) {
$calc=$_;
print $calc."\n";
last;
}
if you run that last one and type 3+5-2, you get 3+5-2.(string "3+5-2", not the number 6)
Why is it so? And how can I get it to calculate the thing?
I have gone through all of the perldoc perlfaqs. Maybe the answer is so simple that I don't see it. I am just trying to build a simple calculator. I have found a rather complicate solution which works, but there must be a very simple solution, isn't it?
Jacques L
_________________________________________________________________
Ontvang je Hotmail & Messenger berichten op je mobiele telefoon met Hotmail SMS http://www.msn.nl/jumppage/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]