in reply to Re^4: keys of hash
in thread keys of hash

Try
@hash{@array} = map 1,@a;
It will map 1 to each member of the array.

Replies are listed 'Best First'.
Re^6: keys of hash
by Fletch (Bishop) on May 18, 2010 at 12:54 UTC

    Using @hash{ @array } = (1) x @array would be more idiomatic. There's no need to get map involved since you really aren't changing the values of the array at all.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      I usually use $hash{$_} = 1 for @array; instead.

      This is very pretty and useful. Filed.
Re^6: keys of hash
by prafull (Novice) on May 18, 2010 at 11:29 UTC
    worked .. thanx a lot