Re: scalar number or string?

2003-01-19 Thread Mystik Gotan
Aye. I once made a simple program, just for calculating + and *. I had no problem with that. Which means somethin' like: #!usr/bin/perl print "Enter a number."; $number = ; # *ing by 2 (can't get to the right word) $result = $number * 2; print "Aye, the result is" . $result; Which you could do

Re: scalar number or string?

2003-01-19 Thread Paul Johnson
On Sun, Jan 19, 2003 at 06:44:31PM +0100, Jacques Lederer wrote: > 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 () { > $calc=$_; > print $calc."\n"; > last; > } > > if you run that last one a

Re: scalar number or string?

2003-01-19 Thread Jenda Krynicky
From: Paul Johnson <[EMAIL PROTECTED]> > On Sun, Jan 19, 2003 at 06:44:31PM +0100, Jacques Lederer wrote: > > When you write > > > > $calc=3+5-2; > > print $calc."\n"; > > > > you get 6. (number, not the string "3+5-2") > > > > When you write > > > > while () { > > $calc=$_; > > print $calc

RE: scalar number or string?

2003-01-19 Thread Oblak, Sasha
You have to compile the input. Try using eval. It should look something like: while () { $calc= eval $_; print $calc."\n"; last; } But, don't forget to catch errors. Sasha > -Original Message- > From: Jacques Lederer [mailto:[EMAIL PROTECTED]] > Sent: Sunday, January 19, 2

Re: scalar number or string?

2003-01-19 Thread R. Joseph Newton
"...if you run that last one and type 3+5-2, you get 3+5-2.(string "3+5-2", not the number 6)" --Jacques Hi Jacques, Well, this is about data types. Unfortunately, Perl tends to haze up the issue by doing away with explicit types and doing everything implicitly. In a programming, as opposed

Re: scalar number or string?

2003-01-19 Thread R. Joseph Newton
And how can I get it to calculate the thing? print eval($calc) ."\n"; Hi Jacques, Sorry. In my previous post, I answered your first question, but offered no solution. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]