in reply to Presenting a local listing of remote files over HTTP

I have always preferred the Cookbook's Recipe 2.17. for 'Putting Commas in Numbers':
sub commify { my $text = reverse $_[0]; $text =~ s/(\d{3})(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; }
This is a Faster Way To Do It. :)

Also, you will probably most likely want to add \z to your regexes that check for archived files:

if ($beta =~ /tar.gz\z/) { ...
to avoid pesky files named something like foo.tar.gz.foo

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: Presenting a local listing of remote files over HTTP
by hacker (Priest) on Jul 03, 2002 at 19:45 UTC
    sub commify { my $text = reverse $_[0]; $text =~ s/(\d{3})(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; }
    Except that your last line above actually reverses the size, so a file of 180,224 bytes becomes 422,081 bytes when returned from commify(). Easy fix: s/scalar reverse/scalar/

    Great tip, and benches a few millis faster in execution time on longer file listings.

      Eh? Doesn't the last line reverse the reversal from the first one, maybe?

      Makeshifts last the longest.