package xmlutil; #-- Use modules use strict; use XML::Simple; #-- Define constants use constant DEBUG => 1; use constant DELIM => ','; use constant XMLFILE => './galaxy.xml'; #-- Define global variables my $gConfig = XMLin(XMLFILE); #-- This is the sub which is used to interface to the #-- main perl code. Had to do this as the C program does not #-- know $gConfig sub get_ival { #-- Get parameter my $pParm=shift; #-- Return the value print get_ivnode(\$gConfig,$pParm); } #-- This is the sub which recursively processes the XML hash array sub get_ivnode { #-- Get parameters my $pPtr=shift; my @pParm = split(DELIM,shift); #-- Define local variables my $lKey; my $lNewPtr; #-- Get the next key $lKey=shift(@pParm); #-- Display debugging information print '[',$lKey,']',"\n" if DEBUG; #-- Return the value if there are no further keys return $$pPtr unless $lKey; #-- Build the new pointer $lNewPtr=$$pPtr->{$lKey}; #-- Call with next node return get_ivnode(\$lNewPtr,join(DELIM,@pParm)); }