skorman00 has asked for the wisdom of the Perl Monks concerning the following question:
$_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: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); }
$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' }]
$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' }]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: foreach not doing what I expect it to be doing
by revdiablo (Prior) on Feb 08, 2006 at 21:19 UTC | |
by Articuno (Beadle) on Feb 08, 2006 at 21:31 UTC | |
by kwaping (Priest) on Feb 08, 2006 at 23:54 UTC | |
|
Re: foreach not doing what I expect it to be doing
by olus (Curate) on Feb 08, 2006 at 21:33 UTC | |
|
Re: foreach not doing what I expect it to be doing
by Anonymous Monk on Feb 09, 2006 at 13:27 UTC |