in reply to Re^2: Write to multiple files according to multiple regex
in thread Write to multiple files according to multiple regex

The conditional to print looked rather fishy, but I forgot about it. Try:

print {$filehandles[$i]} $line - if (/$regex[$i]/../^END_OF_BLOCK/); + if ($line =~ /$regex[$i]/../^END_OF_BLOCK/);

or did you already do exactly that? Please show your updated code.

Replies are listed 'Best First'.
Re^4: Write to multiple files according to multiple regex
by Foodeywo (Novice) on Jul 21, 2015 at 13:03 UTC
    yes I added the $line=~
    print {$filehandles[$i]} $line if $line =~ /$regex[$i]/;
    I dropped the ../^END/ to play with the $/ operator. Not working yet though. Before that I had
    print {$filehandles[$i]} $line if ($line =~ /$regex[$i]/../^END/);
    which redundantly wrote all (correct) lines to the last (not the correct) filehandler.