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
Sharon [ Di, 22 Januar 2008 19:43 ] [ ID #1914101 ]

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
Peter Makholm [ Di, 22 Januar 2008 19:54 ] [ ID #1914102 ]

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
Sharon [ Di, 22 Januar 2008 20:01 ] [ ID #1914104 ]

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/"
Tad J McClellan [ Mi, 23 Januar 2008 03:34 ] [ ID #1914816 ]
Perl » comp.lang.perl.misc » XML Reference problem

Vorheriges Thema: Perl and Qt4
Nächstes Thema: FAQ 9.11 How do I redirect to another page?