XML Reference problem

XML Reference problem

am 22.01.2008 19:43:31 von Sharon

I have an XML hash that has $xmlResults->{Ack} = Failure
I use an if statement with $xmlResults->{Ack} == "Success" and getting
true instead of false.
I about to pull some hairs about and I don't have to many left, please
help me save the last ones I have.


thanks
Arik

Re: XML Reference problem

am 22.01.2008 19:54:59 von Peter Makholm

sharon@blue-linedesign.com writes:

> I use an if statement with $xmlResults->{Ack} == "Success" and getting
> true instead of false.

When comparing strings you have to use the string comparison operator
instead of the number comparison operator. That is to use
'$xmlResults->{Ack} eq "Sucess"' instead.

By using '==' you're comparing the numeric value of both sides, which
is very probale 0.

//Makholm

Re: XML Reference problem

am 22.01.2008 20:01:04 von Sharon

On Jan 22, 10:54 am, Peter Makholm wrote:
> sha...@blue-linedesign.com writes:
> > I use an if statement with $xmlResults->{Ack} == "Success" and getting
> > true instead of false.
>
> When comparing strings you have to use the string comparison operator
> instead of the number comparison operator. That is to use
> '$xmlResults->{Ack} eq "Sucess"' instead.
>
> By using '==' you're comparing the numeric value of both sides, which
> is very probale 0.
>
> //Makholm

I'm not going to be completely bold after all, thanks a lot

Re: XML Reference problem

am 23.01.2008 03:34:20 von Tad J McClellan

sharon@blue-linedesign.com wrote:

> I use an if statement with $xmlResults->{Ack} == "Success" and getting
> true instead of false.


That is what you are supposed to get (because zero does equal zero).


> I about to pull some hairs about and I don't have to many left, please
> help me save the last ones I have.


You should always enable warnings when developing Perl code!


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"