use strict;
use warnings;
$/ = undef;
my $whole_file = <DATA>;
print $whole_file;
print "-" x 20, "\n";
my @sections = split /xxx\n/, $whole_file;
print $sections[0];
print "-" x 20, "\n";
print $sections[1]; #line 14
__DATA__
aaa
bbb
ccc
xxx
yyy
zzz
--output:--
aaa
bbb
ccc
xxx
yyy
zzz
--------------------
aaa
bbb
ccc
xxx
yyy
zzz
--------------------
Use of uninitialized value in print at t.pl line 14, <DATA> chunk 1.
This works:
use strict;
use warnings;
my $string = "abc\nxyz";
my @arr = split /\n/, $string;
print "$arr[0]\n";
print "$arr[1]\n";
--output:--
abc
xyz