in reply to Perl code looping using XML::Twig

First let me advise that you should start use-ing strict and warnings. Today. What you are describing seems like the expected behavior from XML::Twig. Are you asking how to quickly return from 'product' once one of your conditions has been hit? I am no XML::Twig expert but you could do that with a closure like this:
#!/usr/local/bin/perl use XML::Twig; use Net::Telnet(); $db = "hrdm2"; $comm = "stop-$db.sh"; $cachedel = "No"; $done = 0; my $s= new XML::Twig( TwigHandlers=> { Product => \&product}); $s->parsefile( 'testservers2.xml'); exit; sub product { my ($s, $product)= @_; return if $done; my %product; # In all your if/elsif statements add $done = 1; # Rest of your code }

Replies are listed 'Best First'.
Re^2: Perl code looping using XML::Twig
by coding_new (Sexton) on Apr 21, 2009 at 01:23 UTC
    Thanks roubi. That was my issue (adding a closure). I was able to return from product once one of my conditions was met. I will also add everyones recommendation for using strict and warnings going forward. Thanks everyone.