in reply to creates anonymous hashes with hash slices

I'd try this:
my $rhash; for my $key (qw(one two three four)) { $rhash->{$key} = $parm{$key}; }
Of course, you can switch qw(one two three four) with @list_of_keys or (1..6)

update: <homer_simpson>D'oh</homer_simpson>. The following line is what merlyn was referring to:
for my $key (@parm{one,two,three,four)}) {
Which was wrong because that expression returns a list of values corresponding to those keys, while what you want is a list of keys.
It's fixed now. Thanks merlyn!

-- ar0n | Just Another Perl Joe

Replies are listed 'Best First'.
RE: Re: creates anonymous hashes with hash slices
by merlyn (Sage) on Aug 03, 2000 at 21:15 UTC
    Hmm. Do you really want to use the values as keys again? @parm{qw(one two three)} is the values associated with the keys of one, two, and three. But then your loop tries to re-use them as a key once again.

    -- Randal L. Schwartz, Perl hacker