in reply to String replacement
Yet another WTDI:
my ($string_a, $string_b) = ('ABABA','BB--B-BB'); my @a = split '',$string_a; my @b = split '',$string_b; $string_a = ''; my $a_ndx = 0; for (0..@b-1) { $string_a .= $b[$_] eq '-' ? '-' : $a[$a_ndx++] }
This particular version modifies the 'A' string, but it could be trivially modified to preserve that string and build a fresh one; I consider that an advantage, but YMMV.
|
|---|