Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

capturing a hash from an array of hashes 1

Status
Not open for further replies.

sloppyhack

Technical User
Apr 17, 2001
111
US
I am trying to capture a hash from an array of hashes and assign it to one hash. It's not working, but I know it's possible. Here's an example.

my @dups; #my array containing hashes

I want to pash one hash from this array into a hash variable.

$lgth1 = length $dups[$row]->{'ITDESC'}; #assign length value..this works

if ($lgth1 >= $lgth2) {
%best = $dups[$row]; #this may be the problem..trying to assign one row of the array (a hash) to the hash variable
}

print "$best{'ITDESC'}\n"; #this doesn't print anything


Cheers,

Sloppyhack
 
Code:
%best = $dups[$row];

I think this needs to be:
Code:
%best = %{$dups[$row]};

The [tt]@dups[/tt] array contains hash references, not hashes.
 
You rock. That did it. I always get confused with references vs. actual structures. Thanks a bunch!!!

Cheers,

Sloppyhack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top