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.

<-radiant.matrix->
Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law