Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create an array of numbers from 001 - 500 2

Status
Not open for further replies.

sdslrn123

Technical User
Jan 17, 2006
78
0
0
GB
The 001 element (3 figure configuration is important. Is this possible without having to type out all the numbers?
I have tried @nums = (001 .. 500) with no success.
 
Code:
for ($i=1; $i<501; $i++) {
  push @array, sprintf ("%0.3d", $i);
}

print join "\n", @array;
HTH

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
same thing using map:

my @array = map {sprintf "%0.3d",$_} (1..500);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top