Grouping perl foreach values

Michael Still mikal at
Tue Jul 9 11:33:32 EST 2002

On Tue, 9 Jul 2002, Kim Holburn wrote:

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

Yeah, sorry.

> in that case try:
> while (($c1,$c2,$c3) = splice (@list, 0, 3)) {
>   ... do stuff ...
> }

Cool. I've also found that:

while($listofthings[0] ne ""){
  $cola = shift(@listofthings);
  $colb = shift(@listofthings);
  $colc = shift(@listofthings);


does what I want, but is ugly.

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

It starts off life as a parsed C header file. I just iterate through
functions found in the header and pack the things I know onto the end of a
string, using ';' as the delimiter. It would therefore be easy to change
the generation of the string if this made life easier.

I was trying to avoid an array of references though.

Thanks for your help,


Michael Still (mikal at     UMT+10hrs

More information about the linux mailing list