Here's another way to do it:
#!/usr/bin/env perl -l use strict; use warnings; my $string = '---BB--BBB---BBB---B-B---'; print $string; $string =~ y/B/M/; print $string; my @subs = qw{i o}; my $i = 1; $string =~ s/(-+)/$subs[$i ^= 1] x length $1/eg; print $string;
Output:
---BB--BBB---BBB---B-B--- ---MM--MMM---MMM---M-M--- iiiMMooMMMiiiMMMoooMiMooo
-- Ken
In reply to Re: Tips on how to perform this substitution?
by kcott
in thread Tips on how to perform this substitution?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |