in reply to Re: Manually incrementing @ array during for
in thread Manually incrementing @ array during for

Although you already have a working solution, I took this as a puzzle where the array

Here is my (not so serious) solution:

#!/usr/bin/perl use strict; use warnings; my @data = <DATA>; for ((my $i, local $_, my $next) = (0, @data[0, 1]); $i < @data; ($_, $next) = ($next, $data[++$i + 1])) { $next and $next =~ /^\s/ and ($_, $next) = ($_ . $next, $data[++$i + + 1]) and redo; # processing goes here print "#$i: $_"; } __DATA__ keyword1 data1 data2 data3 keyword2 data1 data2 data3 data4 data5 data6 keyword1 data1 data2 data3 data4 keyword3 data1
which gives:
#0: keyword1 data1 data2 data3 #3: keyword2 data1 data2 data3 data4 data5 data6 #4: keyword1 data1 data2 data3 data4 #5: keyword3 data1

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$