Tag perl

[Solved] split string into several substring using indexes

You can use substr() as an lvalue and start replacing the string from right side of it, my $string = ‘GATGCAGTTAGGCGTAGCAGAGTGAGACGACGACGATATTAGGACCCGGTAAGGCACAATATAGC’; my %coord_colors = ( 10 => “red”, 48 => “orange”, 60 => “purple”, ); substr($string,$_,0) = $coord_colors{$_} for sort…