Re: mapping

From: Wiggins D Anconia (wiggins_at_danconia.org)
Date: 06/30/04


Date: Wed, 30 Jun 2004 09:52:21 -0600
To: jack jack <script20042000@yahoo.com>, beginners@perl.org

Please bottom post, and group reply so that everyone can help and be
helped, and to prevent accidental ignoring of your post.

>
> Hello wiggins,
>
> Thanks,
>
> My requirement is i have two arrays @element and @size that i have
got by splitting.
>

Probably you should adjust the code at the 'split' time in anticipation
of your future needs, the need for two arrays that are then combined is
an indication of a design flaw. Post more code to have that looked over...

> I want to map first element of @element with first element of @size
seperated with a colon . (in a loop how should i do it for all elements
in arrays),i want this output in an array @mapped.
>
>
> for eg:
> file1 : 1
> file2 : 2
> file3 : 3
>
> so if say print @c
>
> i should have output as follows
>
> file1 : 1
> file2 : 2
> file3 : 3
>
>

I am assuming the arrays are the same size...

my @c;
foreach my $index (0 .. $#element) {
   $c[$index] = "$element[$index] : $size[$index]";
}

works?

http://danconia.org

<snip old posts>