in reply to match tags
while (@data = <DATA>) { ... }
doesn't make sense. The expression @data = <DATA> reads all lines from the filehandle DATA into @data. End while. Drop it.
Instad of
for($i=0;$i<$#data;$i++){
better say
for my $line (@data) {
That said, I'd do
my @tokens; while (<DATA>) { if (/\.\.(AU|BD):/) { if ($1 eq 'AU') { print join( ',',@tokens),"\n", @tokens = () if @tokens; } chomp (my $line = <DATA>); push @tokens, $line; } } print join( ',',@tokens),"\n", @tokens = () if @tokens;
|
|---|