use strict; use warnings; $/ = undef; my $whole_file = ; 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, chunk 1.