perl -e"BEGIN{$T=join'',map{qq[A$_ ]}split',',shift;@F=split',',shift}" -ple"$_ = join'',(unpack $T,$_)[@F]" "10,4,6,6" "2,1,0,3" infile >outfile