use strict; use warnings; my $string = "abc\nxyz"; my @arr = split /\n/, $string; print "$arr[0]\n"; print "$arr[1]\n"; --output:-- abc xyz