Re: Dynamically creating a hash for keys()

[email protected] (Vladi Belperchinov-Shabanski)
Newsgroups perl.fwp
Organization CSA
Message-ID <[email protected]>
skip values:

%hash = qw( fred filntstone barney rubble tom delong );
print( map { $a=!$a ? $_ : () } reverse( %hash ) );

perhaps not too bad map() example :)

P! Vladi.

On Tue, 19 Oct 2004 09:50:39 -0400
Jason Foster <[email protected]> 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!
> 
> 


-- 
Vladi Belperchinov-Shabanski <[email protected]> <[email protected]>
http://cade.datamax.bg/
Cross the ocean deep, wake now from your sleep
Kiss the past goodbye, don't follow empty skies...
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFBdYGfkBm4tG81shQRAmmFAJ0aiCyCs/eZ2DU4rhW/elojY70qTQCfRVWY
6fmnpWcgq2FP8aQufJD2RZY=
=dsVM
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.