I'm a level 10 C/C++ coder, level 2 ASM coder, and now need to tri-class with Perl. Here is a bit of code I'm having trouble with:
my @bucketList = $_xmlData->{Bucket};
open(DEBUG, ">bucketList.txt");
print DEBUG Dumper(@bucketList);
close(DEBUG);
foreach my $bucket ( @bucketList )
{
open(DEBUG, ">bucket.txt");
print DEBUG Dumper($bucket);
close(DEBUG);
}
$_xmlData holds the data returned from an XML::Simple::XMLin call, Bucket being the key that references an array of all these things called buckets. Dumper is a function in Data (not sure if it's a commonly used tool, but it seems to print out arrays and hashes nicely).
Trying to handle this with a foreach loop, I put all that data into @bucketList. The dump shows that it is all ok. The problem is with my foreach variable, $bucket. I would think that it would be set to each element of @bucketList sequentially. According to the dump, it's actually set to the entire array. What am I doing wrong?
as requested, here are snippets of the dumps:
bucketList:
$VAR1 = [
{
'ExeVersion' => NDA_BLOCKED,
'ModuleVersion' => NDA_BLOCKED,
'ResponseStatus' => NDA_BLOCKED,
'ExeName' => NDA_BLOCKED,
'Priority' => NDA_BLOCKED,
'TotalHits' => NDA_BLOCKED,
'ResponseURL' => NDA_BLOCKED,
'ModuleName' => NDA_BLOCKED,
'BucketID' => NDA_BLOCKED'
},
{
'ExeVersion' => NDA_BLOCKED,
'ModuleVersion' => NDA_BLOCKED,
'ResponseStatus' => NDA_BLOCKED,
'ExeName' => NDA_BLOCKED,
'Priority' => NDA_BLOCKED,
'TotalHits' => NDA_BLOCKED,
'ResponseURL' => NDA_BLOCKED,
'ModuleName' => NDA_BLOCKED,
'BucketID' => NDA_BLOCKED'
},
{
'ExeVersion' => NDA_BLOCKED,
'ModuleVersion' => NDA_BLOCKED,
'ResponseStatus' => NDA_BLOCKED,
'ExeName' => NDA_BLOCKED,
'Priority' => NDA_BLOCKED,
'TotalHits' => NDA_BLOCKED,
'ResponseURL' => NDA_BLOCKED,
'ModuleName' => NDA_BLOCKED,
'BucketID' => NDA_BLOCKED'
}]
bucket:
$VAR1 = [
{
'ExeVersion' => NDA_BLOCKED,
'ModuleVersion' => NDA_BLOCKED,
'ResponseStatus' => NDA_BLOCKED,
'ExeName' => NDA_BLOCKED,
'Priority' => NDA_BLOCKED,
'TotalHits' => NDA_BLOCKED,
'ResponseURL' => NDA_BLOCKED,
'ModuleName' => NDA_BLOCKED,
'BucketID' => NDA_BLOCKED'
},
{
'ExeVersion' => NDA_BLOCKED,
'ModuleVersion' => NDA_BLOCKED,
'ResponseStatus' => NDA_BLOCKED,
'ExeName' => NDA_BLOCKED,
'Priority' => NDA_BLOCKED,
'TotalHits' => NDA_BLOCKED,
'ResponseURL' => NDA_BLOCKED,
'ModuleName' => NDA_BLOCKED,
'BucketID' => NDA_BLOCKED'
},
{
'ExeVersion' => NDA_BLOCKED,
'ModuleVersion' => NDA_BLOCKED,
'ResponseStatus' => NDA_BLOCKED,
'ExeName' => NDA_BLOCKED,
'Priority' => NDA_BLOCKED,
'TotalHits' => NDA_BLOCKED,
'ResponseURL' => NDA_BLOCKED,
'ModuleName' => NDA_BLOCKED,
'BucketID' => NDA_BLOCKED'
}]
Code tags added by Arunbear