Mafj <> writes:
> I have a fixed structure like this (comes from external file):
>
> $self->{data} = {
> 'ver' => 2,
> 'list' => {
> 'name1' => 'item1',
> 'different_name' => 'another_item',
> 'whatever' => 'special_item',
> # and 1000 more
> }
> };
> I need a content of $self->{data}->{list}. I do knot know field names
> nor keys.
> There is probably some simple loop, foreach or while,e.g.
> ( ($c,$v) = each %self->{data}->{list} ).
You're pretty close. To begin with, since $self->{data}->{list} is a
reference to a hash, you need to dereference it with %$ in order to work
with the hash it refers to.
And second, you can get a list of hash keys with the keys (perldoc -f
keys) function:
my @listKeys = keys(%$self->{data}->{list});
sherm--
--
My blog:
http://shermspace.blogspot.com
Cocoa programming in Perl:
http://camelbones.sourceforge.net