Re: Dynamically creating a hash for keys()
[email protected] (Brad Greenlee)
| Newsgroups | perl.fwp |
|---|---|
| Message-ID | <[email protected]> |
PerlMonks is a great place for questions like this:
http://www.perlmonks.org/index.pl?node_id=30013
-b
Jason Foster wrote:
> Can anyone help me to understand why this code refuses to compile?
> Even better, can anyone help fix it :)
>
> %hash = qw( fred filntstone barney rubble tom delong );
> print( keys( reverse( %hash ) ) );
>
> The error message...
>
> Type of arg 1 to keys must be hash (not reverse) at ./killme.pl
> line 4, near ") ) "
>
> ... was pretty confusing since it implies that "reverse" is a type?!
>
> I tried making an anonymous hash as follows...
>
> print( keys( %{ reverse( %hash ) } ) );
>
> ... but got no results at all.
>
> Help!
>