Do you know where your variables are? | |
PerlMonks |
Re: Regex to match range of characters broken by dashesby Cristoforo (Curate) |
on Jul 17, 2016 at 19:20 UTC ( [id://1167921]=note: print w/replies, xml ) | Need Help?? |
Here is a solution using a dynamic regex construct. I've never used it before and learned more about it here.
A fly in the ointment was in the code for our $s (@stops). The code wouldn't work here with a 'my' declaration. 'our' was necessary. This is fairly readable and should work for any number of groups (provided they don't exceed the count of fasta characters in a string of them. I didn't test for that to see how it behaved). The dynamic regex form was necessary because the count of the quantifier changed for each iteration of the 'for' loop ($s-1). The printout after the __END__ token shows the results of the run. Update: Added a final substitution to remove dashes preceding and following the double underscore (as he desired in his post. Missed that.)
In Section
Seekers of Perl Wisdom
|
|