Hi,

On Mon, 11 Jun 2012 07:10:07 -0700
"Ron Bergin" <[email protected]> wrote:

> >lina wrote:
> > Hi,
> >
> >
> > $  for i in `seq -f '%02g' 1 10` ; do echo $i ; done
> > 01
> > 02
> > 03
> > 04
> > 05
> > 06
> > 07
> > 08
> > 09
> > 10
> >
> > I wonder how can I get something like above in the perl.
> >
> perl -e "for (1..10){printf(qq(%02d\n), $_)}"
> 

On Linux with Bash, this command line prints all zeros. This fixes it:

perl -e 'for (1..10){printf(qq(%02d\n), $_)}'

But single quotes are not available on Windows.

Anyway here is a complete program:

[Perl]
#!/usr/bin/perl

use strict;
use warnings;

for my $i (1 .. 10)
{
    my $elem = sprintf("%02d", $i);

    print "$elem\n";
}
[/Perl]

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Stop Using MSIE - http://www.shlomifish.org/no-ie/

He has a high degree of idealism, a high degree of stubbornness, and an even
higher degree of inability to distiniguish between the two.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to