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
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
"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
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
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
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
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 :)
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
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
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 :)
>
10 matches
Mail list logo