use strict; use warnings; my $str = "First line\nsecond line\netc. lines here"; while($str =~ /([^\n]+)\n?/g){ print "LINE: $1\n"; }