use constant EOL_CHAR => "\n";
my $str = '1,2,3\n,4,5,6\n7,8,9';
$str =~ s/,//g;

my @array = split(/\\n/,$str);

$\ = EOL_CHAR; # $\ default null; string printed at end of call to print
foreach(@array) {
  
  print $_;
}

