Jim Gibson <jimsgib...@gmail.com> writes: > 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?
Egad... I really intended to include a few lines of ouput.. I didn't even notice I hadn't... sorry. As it is I get this: stat.pl `ls` [...] 1232649333 man.pl 994039516 mms.perl 1227284469 modulo.pl 994039516 n2mbox.pl 1207227459 next_unless.pl [...] You see some of the files have been modified long enough ago that the epochal time is enough earlier to be one digit shorter. I wanted to see: 1232649333 man.pl 0994039516 mms.perl 1227284469 modulo.pl 0994039516 n2mbox.pl 1207227459 next_unless.pl And in the course of explaining it, as happens to me pretty often.. I see my mistake... Somehow I'd gotten it into my head that since it was 1 digit short I needed to pad 1 zero... Well... thats' true.. but it needs to come at the start of an 11 character parking place.... so anyway, thanks for making me see the error. I seem to forget about 90% of what I know between scripts. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/