Grouping perl foreach values

Kim Holburn kim.holburn at anu.edu.au
Tue Jul 9 11:28:16 EST 2002


I assume you have a list in which case you have to refer to it as a list:
@listofthings not $listofthings
in that case try:

while (($c1,$c2,$c3) = splice (@list, 0, 3)) {
  ... do stuff ...
}

If not how does your data start?  If you have you data initially in text form what delimiters?

At 11:09 AM +1000 02/7/9, Michael Still wrote:
>Hey,
>
>I've surfed and can't find anything on this, although that it probably
>because I don't know the perl word for it.
>
>I have a list of value in the form:
>
>  v1;v2;v3;v4;v5;v6;v7;v8;v9
>
>And I want to work through them in sets of three, something like:
>
>foreach($cola, $colb, $colc) ($listofthings){
>  ... do stuff ...
>}
>
>Can people either suggest how to do this, or suggest how I can refactor
>the problem to make this easier?
>
>Thanks,
>Mikal
>
>--
>
>Michael Still (mikal at stillhq.com)     UMT+10hrs


-- 
--
Kim Holburn  Network Consultant  Ph: +61 2 61258620 M: +61 0417820641
Email: kim.holburn at anu.edu.au - PGP Public Key on request

Life is complex - It has real and imaginary parts.
     Andrea Leistra (rec.arts.sf.written.Robert-jordan)




More information about the linux mailing list