$str=" this is a string example"; @data=map { $_.="\n" } split (/\n/, $data); # equals to @data= ( $data =~ /(.*?\n)/g );