in reply to Creating Array from Hash that pulls only Unique values while iterating over each Unique Value

OK. Let's create a second hash whose keys are the array you need.

# Put this after defining %ItemUID. my %hvalues; # instead of my @hvalues. ... if (not exists $ItemUID{$uid}) { $ItemUID{$uid} = $src } # At end of first while loop, insert this line after the one above. if (not exists (%hvalues{src})) { %hvalues{src} = 1; }

Then keys %hvalues will get you the array you need. You could always say my @hvalues = keys %hvalues; if clarity of that type is needed.

  • Comment on Re: Creating Array from Hash that pulls only Unique values while iterating over each Unique Value
  • Select or Download Code