Another suggestion is to perhaps assign your values prior to testing as well.
XML parsers can create a pretty convoluted data structure.
assign the value your looking for.
warn the value prior to the conditional logic
and see if your logic operates correctly.


# add me before  your conditional block assuming you re-assign to x, y and z
warn "$z is defined (X)$x\t(Y)$y" if defined ($z);

if ( ( $x || $y ) && defined ($z) ) {
}
is much easier than trying to traverse the XML parser returned structures

this really isnt a solution, just a suggestion, im new and when dealing with a complex structure like the one you are, for me, it gets a bit easier when I stick to basics, re-assign so you know whats what and avoid some short cuts like making sure you use the braces () when calling a function defined. i have sometime found i am trying to use a value ina function call that isnt making it because i built the query wrong (like i said im beginner level)


----- Original Message ----- From: "Charles K. Clarkson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 18, 2004 3:02 PM
Subject: RE: Simple if conditional



Kevin Old <> wrote:

: Hello everyone,
:
: I have an if statement that has three different clauses that
: need to be met before it should be executed, and for some
: reason I can't get the conditionals to work.  Here's the snip
: of code:


Start smaller, with something you know works and build up from there. Testing will show this is the better approach.

if (   1

   && 1

   || 0

   ) {

   print "*********IT WAS DELIVERED*******\n";
}

   Now substitute the second 1.


if ( 1

   && $activity
       ->child('Status')
       ->child('StatusCode')
       ->child('Code')
       ->value eq 'DS'

   || 0

   ) {

   print "*********IT WAS DELIVERED*******\n";
}

   If it fails here, you have a problem in that value.
If it succeeds, you have a problem with the "defined"
value.

: print "STCode:
: ",$activity->child("Status")->child("StatusType")->child("Code
: ")->value,"\n"; # This line prints I
: print "SCCode:
: ",$activity->child("Status")->child("StatusCode")->child("Code
: ")->value,"\n"; # This line prints DS

  These are not really useful because some white space may be
hidden. Wrapping the text in quotes should show it.

printf qq(STCode: "%s"\n),
   $activity->child('Status')
       ->child('StatusType')
       ->child('Code')
       ->value;

printf qq(STCode: "%s"\n),
   $activity->child('Status')
       ->child('StatusCode')
       ->child('Code')
       ->value;


HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to