use warnings; use strict; use XML::Twig; my $xml = < 7777 /extra/localcw/opt/APP/sun4 V36.11.01 /usr/localcw/opt/APP/Solaris-2-9-sparc-64 glanceSunOS 5.9 (Solaris 9) (sparc, 64 Bit) 7.3.00.6059 Jul 19 2006 3.0 root 90 StAR-201105090928.tar No download file found f9a64ef61c * flower P XML my $twig = XML::Twig->new( twig_roots => {'APPLICATION' => \&doStuff, 'ACL' => \&doStuff} ); $twig->parse($xml); sub doStuff { my ($t, $elt) = @_; print "Found ", $elt->tag(), "\n"; $t->purge; # frees the memory }