XML Reference problem
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
sharon [at] 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
On Jan 22, 10:54 am, Peter Makholm <pe... [at] makholm.net> wrote:
> sha... [at] 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
sharon [at] blue-linedesign.com <sharon [at] 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/"