[Buffalo-pm] Question: How to iterate through 2 arrays andmerge columns

Shaun Griffith sgriffit at gennum.com
Tue Jul 5 07:30:17 PDT 2005


You may want something like this:

    foreach my $i ($i=0;$i<@red;$i+=4)
    {
        printf "%s\t" x 8 . "\n", @red[$i..$i+3], at green[$i..$i+3];
    }

This assumes that you have checked that @red and @green are the same length,
and multiples of 4. (Use whatever is appropriate for the "%s" descriptor.)

-Shaun


> -----Original Message-----
> From: buffalo-pm-bounces at pm.org [mailto:buffalo-pm-bounces at pm.org]On
> Behalf Of Shankar, Ganesh
> Sent: July 5, 2005 9:17 AM
> To: Jim Brandt
> Cc: buffalo-pm at pm.org
> Subject: Re: [Buffalo-pm] Question: How to iterate through 2 arrays
> andmerge columns
> 
> 
> Thanks for your reply.  
> 
> The two arrays each hold 4 elements per line.  There are 
> approx. 18,000
> lines per file. The final line should contain 8 elements, after
> processing.  The first 4 would be from @red_elements and the second 4
> would be from @green_elements.
> 
> So, in your solution, would $red_items[$i] represent the entire line
> consisting of all 4 elements?
> 
> -Ganesh
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 2184 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/buffalo-pm/attachments/20050705/59f5d5e3/winmail.bin


More information about the Buffalo-pm mailing list