Skip to content

Instantly share code, notes, and snippets.

@mshock
Created May 30, 2012 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mshock/2836530 to your computer and use it in GitHub Desktop.
Save mshock/2836530 to your computer and use it in GitHub Desktop.
recursive string snip
#!perl
my $str = '.,a..A,,C..+4ACGTG.,-2TG,,...,a.';
print replace($str);
sub replace {
my $str = shift;
if ($str =~ m/([+-])(\d+)/) {
$str =~ s/\Q$1\E$2.{$2}//;
return replace($str);
}
return $str;
}
@mshock
Copy link
Author

mshock commented May 30, 2012

delete # of characters within string following a + or - and integer length specifier recursively

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment