in reply to How to insert a "/" within a string?
Just write it as two mutually recursive functions:
(Don't take this answer seriously.)$_ = "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";
|
|---|
| 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 |