Gossamer Forum
Home : General : Perl Programming :

Using 0 (zero) as a Value?

Quote Reply
Using 0 (zero) as a Value?
I set up a configuration file (example)

#do something
#(1=yes do something, 0=no don't)
#---------------------------------------
$varSomething = "0";


if ($varSomething) {big fun}
else {no fun at all}

Now, when I run this script it gives an error when the value is set to "0".

"...file did not return a true value at line blah"

Of course, I thought that was the whole point of 1 or 0. Any pointers?

In the mean time I simply changed the instructions to use 1=yes and 2=no and then used
if ($varSomething == "1") { } else { }

Any help is much appreciated...

Also, how do I do a "timer" for input? I have $inPut = <STDIN>; (and then what to do if yes or no, etc) but I'd like someway to kill the program if no input for 60 seconds or so.
Subject Author Views Date
Thread Using 0 (zero) as a Value? Watts 3052 Jan 9, 2004, 11:34 AM
Post Re: [Watts] Using 0 (zero) as a Value?
Andy 2970 Jan 9, 2004, 12:26 PM