Split string into several substring using indexes
I have this string and hash: Input data: my $string = 'GATGCAGTTAGGCGTAGCAGAGTGAGACGACGACGATATTAGGACCCGGTAAGGCACAATATAGC'; my %coord_colors = ( 10 => "red", 48 => "orange", 60 => "purple", ); I want to "open" the string at each hash key position, and insert the key-value. See the desired output to have an idea about what I'm trying to explain: Desired output: GATGCAGTTAredGGCGTAGCAGAGTGAGACGACGACGATATTAGGACCCGorangeGTAAGGCACAATpurpleATAGC I know about the substr and split functions, but I'm not sure about how to divide a string into several parts "simultaneously" and then introduce another str
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.