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

Re: printf and zero padding

Thread Previous | Thread Next
From:
Jim Gibson
Date:
October 24, 2009 14:36
Subject:
Re: printf and zero padding
Message ID:
p06240800c70922f303be@[192.168.1.3]
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.
>
>cat script.pl
>
>   #!/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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About