peterc has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I am trying to make sense of some code that I have inherited it contains an array of hashes
I am able to get the hash that I want to modify, and I use this piece of code to get the values out but

my @attributes = $line->attributes; for my $attribute (@attributes) { my $values = $line->get($attribute); for my $v (@{$values}) { push (@result_array, $v); } }
The problem that I have is that I would also like to modify the hash and replace it back inside the original array but I cant find any documentation about the $line->get($attribute) section. Can anyone tell me how to do the reverse of this?
Many Thanks
Peter

Replies are listed 'Best First'.
Re: Getting and replacing an item of a Hash
by Joost (Canon) on Aug 11, 2004 at 10:11 UTC
Re: Getting and replacing an item of a Hash
by Limbic~Region (Chancellor) on Aug 11, 2004 at 12:48 UTC
    peterc,
    This is a badly worded title for the question you are actually asking. I would consider the node and suggest an alternative, but unfortunately I have no idea what module you are using here.

    Typically, the documentation for the module that $line is would tell you what public methods are available. Common sense would say if there is a get method, the set method, if there was one, would be set.

    If this is not the case there is a way to access the object's internal structure directly (not through accessor or mutator methods), but that is typically frowned upon. You will need to look at the source or at least tell us what module you are using.

    Cheers - L~R

      Hi,
      Thankyou for looking at this for me the module was Net::Ldap I have just found the documentation answering my question.
      My problem was that when I started this morning I thought that I wes dealing with a simple hash, but what I am actually dealing with is a container with its own stucture :-(
      So what I really need to do is get my head around moving around and modifying the attributes inside it. I will post some code when I figure it out :-)