Dynamically creating a hash for keys()

2004-10-19 Thread Jason Foster
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 l

Re: Dynamically creating a hash for keys()

2004-10-19 Thread Craig S . Cottingham
On Oct 19, 2004, at 08:50, 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 ke

Re: Dynamically creating a hash for keys()

2004-10-19 Thread Aaron J. Mackey
"reverse" returns a list, not a hash; "keys" expects to see something that starts with %. So you could do this to actually dereference an anonymous hash (your version didn't actually make an anonymous hash): print keys %{ { reverse %hash } }; Of course you could have just done: print values

Re: Dynamically creating a hash for keys()

2004-10-19 Thread Brad Greenlee
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 ); pri

RE: Dynamically creating a hash for keys()

2004-10-19 Thread Allen, Greg
print values %hash Greg -Original Message- From: Jason Foster [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 19, 2004 2:51 PM To: [EMAIL PROTECTED] Subject: Dynamically creating a hash for keys() Can anyone help me to understand why this code refuses to compile? Even better, can an

Re: Dynamically creating a hash for keys()

2004-10-19 Thread Bernard El-Hagin
Well, this is hardly fun, but... 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

Re: fwp Digest 19 Oct 2004 13:50:49 -0000 Issue 310

2004-10-19 Thread Gaal Yahas
Jason Foster <[EMAIL PROTECTED]> wrote: This is probably not the place for these kind of questions, but here goes anyway. > Can anyone help me to understand why this code refuses to compile? > > Even better, can anyone help fix it :)

Re: Dynamically creating a hash for keys()

2004-10-19 Thread Vladi Belperchinov-Shabanski
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 r

Re: Dynamically creating a hash for keys()

2004-10-19 Thread majcher
Vladi Belperchinov-Shabanski <[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. Or, you can do it the regular old un-fun way, and just use a seco

Re: Dynamically creating a hash for keys()

2004-10-19 Thread Vladi Belperchinov-Shabanski
On Tue, 19 Oct 2004 16:10:01 -0500 [EMAIL PROTECTED] wrote: > > Vladi Belperchinov-Shabanski <[EMAIL PROTECTED]>: > > :skip values: > : > :%hash = qw( fred filntstone barney rubble tom delong ); > :print( map { $a=!$a ? $_ : () } reverse( %hash ) ); > : > :perhaps not too bad map() example :) >