in reply to Having trouble looping through a data structure

Invest time in reading about data structures, Perl Data Structure Cookbook -perldsc - can be a good start, these come in handy and they are not difficult but are not easy too...

The function ref can allow you to make many useful decision with respect to the type of dereferencing task appropriate for a given segment of the data structure, for example, if 'ref' returned 'ARRAY' when you are looping through a hash you could probably access that particular array by dereferencing it as

foreach my $element (@{$hash{$key}}{ #work on $element; }

uncomment lines to see the returned value of 'ref' and compare that to the subsequent dereferencing approach chosen...
use strict; use warnings; use Data::Dump qw(pp); my %hash; push @{$hash{'article'}},{}; $hash{'article'}[0]= {'SKU'=> ['CDS0013'], 'InternalSKU'=>'179', 'Avai +lableItems'=>['100']}; $hash{'article'}[1]= {'SKU'=> ['CDS0014'], 'InternalSKU'=>'180', 'Avai +lableItems'=>['102']}; foreach my $key (keys %hash){ #print ref $hash{$key},"\n"; foreach my $element (@{$hash{$key}}){ # print ref $element,"\n"; $articleCount = scalar @{$hash{$key}}; #get the coun +t ... foreach my $innerKey(keys %{$element}){ print "$element->{$innerKey}","\n"; #some mor +e referencing yet } } } print "there are $articleCount articles\n"; print pp \%hash;

Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.