Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Newbie sprintf question. I have a string TEST and I want to append zeros so that I have TEST0000.
Trying the following yields 0000TEST:
my $string = 'TEST'; $string = sprintf "%08s", $string;
So after reading a bit more, I tried this thinking that the zeros would appear after the string:
my $string = 'TEST'; $string = sprintf "%-08s", $string;
But that gives me "TEST " (note the 4 blank spaces instead of zeros). I'm sure I'm missing something obvious.
janitored by ybiC: Retitle from "sprintf question" for better search results
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sprintf question
by matija (Priest) on Mar 15, 2004 at 16:43 UTC | |
|
Re: sprintf question
by kvale (Monsignor) on Mar 15, 2004 at 16:27 UTC | |
by Anonymous Monk on Mar 15, 2004 at 16:33 UTC | |
|
Re: sprintf question
by Tomte (Priest) on Mar 15, 2004 at 16:46 UTC | |
|
Re: sprintf question
by BrowserUk (Patriarch) on Mar 15, 2004 at 19:20 UTC | |
|
Re: sprintf question
by TomDLux (Vicar) on Mar 15, 2004 at 19:08 UTC | |
|
Re: sprintf question
by AcidHawk (Vicar) on Mar 16, 2004 at 08:45 UTC | |
|
Re: sprintf question
by ysth (Canon) on Mar 16, 2004 at 03:37 UTC |