in reply to Splitting a Text File
If you use parentheses in the separator given to split, the captured string will also be part of the resulting array. See this example:
use strict; use warnings; use Data::Dumper; my $file = "start<<<<part2>>>>middle<<<<part3>>>>end"; my @parts = split /<<<<(.+?)>>>>/, $file; print Dumper \@parts;
which results in
$VAR1 = [ 'start', 'part2', 'middle', 'part3', 'end' ];
and gives you the content for your splitted files and the names in alternation.
|
|---|