in reply to Re: Re: Packages, references, & data hiding...
in thread Packages, references, & data hiding...

It is quicker to return a hash ref, and if you have the hash ref you can still manipulate that hash...just do it like this:

my $buddys = $p->BuddyList; #this returns a hash ref
for (keys %{$buddys})
{
    print "GROUP: $_\n";  #I'm asuming that 'keys' here was a reference to $keys in your foreach...
    print "NAMES: ", join (' ', @{$buddys->{$_}}), "\n";  #similarly, I removed $keys and so I'm using $_
}

This gives you the speed of using a reference (incedentally, for only a few pieces of punctuation more, you can do the same thing with Indenties and use an arrayref), along with the ease of an actual hash (in the end, that's what it is). you could feasibly get away with

foreach ( keys %$buddys )
But I always find it safer to wrap the ref in braces.
  • Comment on Re: Re: Re: Packages, references, & data hiding...