in reply to Re^2: While in XML document
in thread While in XML document
You don't need to assign to the individual elements of the arrays, set the whole array at once. Instead of
use just$vehicledata[0] = $vh->{year}; $vehicledata[1] = $vh->{make}; $vehicledata[2] = $vh->{model}; $vehicledata[3] = $vh->{vin}; $vehicledata[4] = $vehiclecount; $vehiclecount++;
or even@vehicledata = ( $vh->{year}, $vh->{make}, $vh->{model}, $vh->{vin}, $ +vehiclecount++);
@vehicledata = ( @{$vh}{year, make, model, vin}, $vehiclecount++);
Hopefully it'll make the problem more apparent. You dutifully assign to @driverdata and @vehicledata in loops, but do the printing outside the loop. So if there are several drivers or vehicles in the XML you only print the last one. I'm not sure what do you want to do if there are both several drivers and vehicles though.
P.S.: The stuff you are printing is not XML so I don't think the filehandle should be named XMLFILE.
|
|---|