in reply to Hash slices and too many keys

Update: I got the following to work, but it's really ugly...

my @keys = (1 .. 5); my @values = (6 .. 8); my %hash; @hash{@keys} = (@values, ('') x (@columns - @values));
There has to be a better way than that ...
  • Comment on Re: Hash slices and too many keys (Update cause I can't edit a root node)
  • Download Code

Replies are listed 'Best First'.
Re: Re: Hash slices and too many keys (Update cause I can't edit a root node)
by lestrrat (Deacon) on Jul 28, 2001 at 00:07 UTC

    Well, the straight forward way would be

    foreach( 0 .. $#keys ) { $hash{ $keys{ $_ } } = $values{ $_ } || ''; }