Hello,
I am new to Perl and trying to write a Perl program to read in an XML file and generate C code (a pointer array of 246 variables) based on the XML file contents. I was having trouble using a numeric variable for a 'for' loop in the array for XML::Simple and wondering if someone can provide insight on what I am doing wrong. The code looks like this,
use XML::Simple;
use Data:

umper;
$xml = new XML::Simple (KeyAttr=>[]);
#read XML files
$conf_data = $xml->XMLin("tempConfigDataFile.xml");
open CFILE, ">ACM_FM.c";
print_global_defs();
sub print_global_defs
{
my @FC_Names = @{ $conf_data->{'SW-SYSTEMS'}->{'SW-SYSTEM'}->{'CONF-SPEC'}->{'CONF-ITEMS'}->{'CONF-ITEM'} };
my $FC_Count = @FC_Names;
for(my $i = 0; $i < $FC_Count; $i++) {
print CFILE "&", @FC_Names['$i']->{'CONF-ITEMS'}->{'CONF-ITEM'}->{'CONF-ITEMS'}->{'CONF-ITEM'}->[0]->{VT}, "}\n";
}
}
The problem is that inside the 'for' loop, the variable $i in @FC_Names['$i] always gets evaluated to 0 and it always returns the same element (first one) from the XML file. Thus the c file gets printed out with the same element (the first one) repetatively instead of all the elements consecutively.
Can anyone tell me how to correctly reference the numeric variable 'i' inside the array FC_Names so that the correct value of i is used as an index insde the array such that the correct element of the XML file is referenced?
I would appreciate any help.
Thanks!