SPUG: returning variables from subs
Brittingham, John
john.brittingham at attws.com
Tue Jun 19 11:10:40 CDT 2001
How do I get $summary_var, $problem_var, $subproc_xml_var into the First
Subroutine. I can print the veriables in the nested sub but not in the first
sub.
I have tried to declare them but they show up as empty.
Help.
sub process_text
{
use XML::Twig;
my $file = $_;
my $twig= new XML::Twig( # create the
twig
TwigHandlers => { '/CCML3' =>
\&get_xml_text } # call sub when a module
);
# element is parsed
$twig->safe_parsefile( $file); # process the twig
print "\nInside first sub= ".$summary_var, $problem_var,
$subproc_xml_var;
}
sub get_xml_text
{
my( $twig, $module)= @_; # handlers are always called with those 2
arguments
my $e_name = $module->first_child( 'SUMMARY'); # get the
elements
my $p_name = $module->first_child( 'PROBLEM'); # get the
elements
my $s_name = $module->first_child( 'FIX')->first_child(
'SUBPROC'); # get the elements
my $summary = $e_name->text || print "SUMMARY not Found\n";
# get their text
my $subproc_xml = $s_name->sprint(1) || print "FIX not
Found\n"; # get their text
my $problem = $e_name->text || print "PROBLEM not Found\n";
# get their text
chomp ($summary);
chomp ($problem);
chomp ($subproc_xml);
my $summary_var="$summary";
my $problem_var="$problem";
my $subproc_xml_var="$subproc_xml";
print "\nInside nested sub= ".$summary_var, $problem_var,
$subproc_xml_var;
# purge and return the info
$twig->purge; # purges the twig
return $summary_var, $problem_var, $subproc_xml_var;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/spug-list/attachments/20010619/40896a94/attachment.htm
More information about the spug-list
mailing list