On 28 October 2011 12:40, Gary <[email protected]> wrote:
>> Thanks.
>
> Sh1t. How do I use this in a foreach, please?
>
> Trying
> foreach my $key (sort keys $self->{_cfg} ) {
> I get "Type of arg 1 to keys must be hash (not hash element)"
>
foreach my $key (sort keys %{ $self->{_cfg} } ) {
# do stuff
}
%{ $reference } makes it clear to `keys` that the item at the end of
the reference is a hash and not the scalar $self. The braces {} around
the reference are optional.
Hth,
Dp.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/