in reply to How can I do this action WITHOUT split?

my $chars = $str_no_dash; my $final_string = $str_with_dash; $final_string =~ s{[^-]}{substr($chars,0,1,'')}ge;

Dave.

Replies are listed 'Best First'.
Re^2: How can I do this action WITHOUT split?
by Anonymous Monk on Feb 22, 2014 at 17:28 UTC

    Beat me to it!

    my $r = reverse $str_no_dash; $str_with_dash =~ s/[^-]/chop $r/ge;

Re^2: How can I do this action WITHOUT split?
by McA (Priest) on Feb 22, 2014 at 17:19 UTC

    Chapeau! I do forget always that you can put a function in the right part of the substitute command.

    McA