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. #### use strict; use warnings; my $string = "abc\nxyz"; my @arr = split /\n/, $string; print "$arr[0]\n"; print "$arr[1]\n"; --output:-- abc xyz