in reply to How to insert a "/" within a string?

Just write it as two mutually recursive functions:

$_ = "ABCOPCOGNHVCOHL"; my $P = sub { my($p, $q, $e, @s) = @_; $e, @s ? &{"C" ne $e ? $p : $q} +($p, $q, @s) : () }; my $Q = sub { my($p, $q, $e, @s) = @_; ("O" ne $e ? () : "/"), &$p($p, + $q, $e, @s) }; print join "", &$P($P, $Q, split //), "\n";
(Don't take this answer seriously.)

Replies are listed 'Best First'.
Re^2: How to insert a "/" within a string?
by choroba (Cardinal) on Feb 21, 2012 at 11:34 UTC
    In fact, one should be inserting ⚡ instead of /, and it should go between C and D, not C and O:
    $string = 'ACDC';