develooper Front page | perl.beginners | Postings from October 2009

Re: printf and zero padding

Thread Previous | Thread Next
Jim Gibson
October 24, 2009 14:36
Re: printf and zero padding
Message ID:
At 4:02 PM -0500 10/24/09, Harry Putnam wrote:
>With this little script, how would I manage to get the shorter
>timestamps zero padded using printf?  I now how to get padded numbers
>but not when I'm pushing off the right margin too.
>   #!/usr/local/bin/perl
>   use strict;
>   use warnings;
>   while (my $file = shift @ARGV){
>     my @stat = stat $file;
>     printf "%11d %s\n",$stat[9],  $file;
>   }

I am not clear on what you are asking. You would use the format 
conversion '%011d' to zero-pad a number to fill 11 characters, but 
you say you know that already. Can you give an example of your 
desired output?

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About