On Thu, Jul 26, 2001 at 04:52:28PM -0400, Jeff 'japhy/Marillion' Pinyan wrote:
> On Jul 26, Mooney Christophe-CMOONEY1 said:
> 
> >@b=qw/-x 24 -y 25 -z 26/;
> >
> >Is there a nice way to merge the hash implied by @b into %a to get
> 
>   while (@b) {
>     my ($k, $v) = splice @b, 0, 2;
>     $a{$k} = $v;
>   }

Just to be helpful and/or annoying:

    while (my($k, $v) = splice(@b, 0, 2)) {
        $a{$k} = $v;
    }


or you can be non-destructive:

    for (my $i = 0; $i < @b; $i += 2) {
        $a{$b[$i]} = $b[$i+1];
    }


>   %a = (%a, @b);

I've always preferred this unless %a is very large.


Who wants to bet this will be another thread exemplifying TMTOWTDI?


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to