$string = "1,2,3\n,4,5,6\n7,8,9";
@array = split(/\n/,$string);
$max = @array;   # 3 elements
for ($i=0; $i < $max; $i++)
{
  $array[$i] =~ s/,//g;
  
  print $array[$i],"\n";
}