http://www.perlmonks.org?node_id=568188


in reply to Golf: Replacing part of a string with "*"

Maybe a regex:

$string =~ s/^\d{12}/'*' x 12/e; # ************5678

Replies are listed 'Best First'.
Re^2: Golf: Replacing part of a string with "*"
by ikegami (Patriarch) on Aug 18, 2006 at 15:32 UTC
    If the OP wanted to hardcode the length, he could have done
    substr($string,0,-4,'*'x12);

    Much clearer.