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

printf "%-12.12s****\n", '5424123412345678';;

Update: Hmm. Misread your code. I thought you were obscuring the last 4 digits.

This will do the first twelve for a score of ...um...either 0 or -30-somthing :)

[0] Perl> printf "************%4.4s\n", '5424123412345678';; ************5424

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Golf: Replacing part of a string with "*"
by ikegami (Patriarch) on Aug 18, 2006 at 15:44 UTC
    Still not right. It should be printing the *last* four (************5678).

      Ah! Then

      printf "************%s\n", substr('5424123412345678', -4);; ************5678

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.