I've always liked doing it this way, but that's just me:

for my $i (0..100) {
        my $fi='0'x(3-length($i)).$i;
        print "$fi\n";
}

Note that it pads to 3 characters.  If you want 2, change the 3 to a 2.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Horst
Walther
Sent: Monday, June 12, 2006 1:03 PM
To: [email protected]
Subject: formatted output to a variable

Hi, dear colleagues.
In a script I wish to build a name (string), which consists also an
countervalue, derived from a loop counter. 
For the small values (0 to 9) shall the string consist the leading zero
(00 .... 09). 
Whats to do?  
At the moment I dont see the solution, so big the door is!

Please help me!


Horst

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to