in reply to Re: Tips on how to perform this substitution?
in thread Tips on how to perform this substitution?
It can be done in one s/// operation...
use v5.10; use strict; use warnings; $_ = '--BBB----BB--B-------B--B--BBBB---B--'; s ((B+|.)) { state $char = 'i'; if (index($1, 'B') == 0) { $char = $char eq 'i' ? 'o' : 'i'; 'M' x length($1); } else { $char; } }eg; say;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Tips on how to perform this substitution?
by Tux (Canon) on Jan 22, 2014 at 14:47 UTC |