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

my $string= '62880147894644072'; substr( $string, 0, -4 ) =~ tr//*/c; print $string, $/;

Note that I substituted my own credit card number for yours in my test code. ;)

Update: ++ to Sidhekin for out golfing me while I was previewing. ( I like this solution because I find it clear, not because it involves fewer keystrokes. :)

- tye        

Replies are listed 'Best First'.
Re^2: Golf: Replacing part of a string with "*" (lvalue substr)
by kwaping (Priest) on Aug 18, 2006 at 17:48 UTC
    I like this solution a lot as well, both for clarity and because it maintains the flexibility of the original code demonstrated in the update to my original post. Very elegant.

    ---
    It's all fine and dandy until someone has to look at the code.