I need to create a "obscuring" function which replaces clear-text password in line, before writing it to log.
It looks like this:
function pass_obscure {
my $logline = shift;
my $pass = "wer32pass$"; # this password is an example, the real one is received as parameter, or already stored as global value
$logline =~ s/$pass/*********/g;
return $logline;
}
But this, of course, doesn't work. The '$' sign in the password string is interpolated as an endline character, so there's no match, and so replacement doesn't work.
How can I resolve this?
Thanks.