On Fri, 2009-07-10 at 20:32 +0200, Matteo Riva wrote:
> Hello everybody, I have two lists and I want to merge them like this:
> 
>     element 1 of list A, element 1 of list B, A2, B2, A3, B3, etc.
> 
> I need this to create a sequence of key/value for an anonymous hash.
> 
> I'm using this code:
> 
>     # @fields contains the names of the hash keys
>     # $val is a string containing a colon-separated sequence of vales to
>     # be associated with the keys
> 
>     my $count = 0;
>     $data{$key} = { map { $fields[$count++] => $_ } split (/:/, $val) };
> 
> which uses a counter variable.  I was wondering it there's a more
> elegant (AKA perlish) way to mix two lists in this way.
> 
> Thanks!
> 

Download List::MoreUtils from CPAN
http://search.cpan.org/~vparseval/List-MoreUtils-0.22/lib/List/MoreUtils.pm

and use mesh().


-- 
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to