
jr
Novice
Feb 23, 2000, 1:51 PM
Post #1 of 4
(1708 views)
|
Formatting numbers
|
Can't Post
|
|
Okay, so I've written a few scripts and they seem to do what they want, but I am still refining certain techniques...this week's pain is formatting a number in standard number form, such 1,000, 10,000 etc etc rather than 1000 and 10000 etc etc. I've been looking at sprintf to do it, but I am not quite getting the format correctly, atleast I don't think I am. I have a few counting statements which count files in a directory...currently the counts are less than 999, but when they increase above that, I'd like them to look like human numbers: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> opendir THEDIR, "$basepath$key" | | die "Unable to open directory: $!"; @allfiles = grep -T, map "$basepath$key/$_", readdir THEDIR; closedir THEDIR; $numfiles = @allfiles;</pre><HR></BLOCKQUOTE> So I am looking for a way to format the variable of $numfiles to 1,000 or 10,000 (etc)...can anyone point me in the right direction?
|