in reply to Re: replace and remove spaces
in thread replace and remove spaces

Another approach,

perl -le '$var = "12 Ali Engineer B889 Middle town USA"; print join ",",map {s/\s+//g;$_} split /\s+/,$var,4' 12,Ali,Engineer,B889MiddletownUSA