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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array and hash problems. 2

Status
Not open for further replies.

peterneve

Programmer
Joined
Jan 24, 2002
Messages
50
Location
GB
I am susing XML::Simple to read an XML file. I have forced it to use arrays, so I can access items like this:

Code:
  print "$config1->{level1}->[0]->{level2}->[0]->{level3}->[0]";

This is great, but level3 is a hash and I want the keys of the hash. If I use something like:

Code:
  %hash=$config1->{level1}->[0]->{level2}->[0];
  @keys=keys(%hash);

I just get: HASH(0x23a11d4)

I know this probably just need dereferencing somehow but I can't work it out.

Any ideas? ;-)

Thanks in advance...
 
Try this:

Code:
@keys = keys(%{$hash});
 
Maybe:
Code:
%hash=[COLOR=red]%{[/color]$config1->{level1}->[0]->{level2}->[0][COLOR=red]}[/color];
@keys=keys(%hash);

--------------------

Denis
 
Thanks, both answers work fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top