in reply to Re^2: promoting array to a hash
in thread promoting array to a hash

Oh, Ok, you almost have it, @a = sort keys %{{a=>1,b=>2,c=>3}}; or in terms of your original problem, @a = sort keys %{{ map {$_ => undef} map {split} <> }}; Notice the replacement of parens with curlies. That makes the hashlike list into a hash reference to its contents, and the outer %{} dereferences it.

I agree with your desire to avoid temporary variables, I try to do that, too, in perl.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^4: promoting array to a hash
by sleepingsquirrel (Chaplain) on Jun 13, 2004 at 06:07 UTC
    thanks, that's just what I was looking for.
    print "$_\n" for sort keys %{{map {$_,1} grep /^[a-z]+$/, (split /\s/, + join(" ",<>))}};