in reply to Re: edge case in substitution?
in thread edge case in substitution?

This is actually a nice approach, especially since it automatically deals with the other edge condition mentioned by ysth below, as well as the one cited in the OP.

But I think you missed some of the details -- the monk only wants to put in asterisks for certain paramters in the string:

sub obscure { my ($self, $s) = @_; my %tags = qw/fred x wilbur x/; return join '&', map { my ($n,$v) = split /=/; ( exists( %tags{$n} )) ? "$n=".'*' x length($v) : $_ } split /\&/, $s; }
(Sorry, but I didn't see the relevance/need for "use constant" there, so I left it out.)

(updated to fix indentation in the code)