Click to See Complete Forum and Search --> : simple question


msgsbox
February 25th, 2006, 07:36 PM
Just start learn Perl..

I try this:

$in1=<STDIN>;
$in2=<STDIN>;

$x1=$in1==$in2;
print("$x1");


Question:
enter 1 and 1, I got 1;
but enter 1 and 2, I got nothing, suppose to be 0, right?

visualAd
February 26th, 2006, 05:54 AM
The value it holds is actually false. False can also be represented by a null string. Convert it to an integer and you'll see 0:

$x1 = (integer) ($in1 == $in2);

msgsbox
February 26th, 2006, 05:07 PM
The value it holds is actually false. False can also be represented by a null string. Convert it to an integer and you'll see 0:

$x1 = (integer) ($in1 == $in2);

Thank you!