On 28 October 2011 12:40, Gary <listgj-gc...@yahoo.co.uk> 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: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to