Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: using the stat function

by gav^ (Curate)
on Jun 12, 2002 at 13:05 UTC ( #173801=note: print w/ replies, xml ) Need Help??


in reply to using the stat function

This should probably do the trick:

opendir(DIR, $user{site_id}) || die "Unable to open directory $user{site_id}: $!"; my @userfiles = sort grep !/^\.\.?\z/, readdir DIR; close DIR; foreach my $file (@userfiles) { my $size = format_size(-s "$user{site_id}/$file"); print $size, "\n"; } sub format_size { my $bytes = shift; if ($bytes >= 1048576) { return sprintf("%.2f MB", $bytes / 1048576); } elsif ($bytes >= 1024) { return sprintf("%.2f KB", $bytes / 1024); } else { return "$bytes Bytes"; } }

gav^


Comment on Re: using the stat function
Download Code
Replies are listed 'Best First'.
Re: Re: using the stat function
by Anonymous Monk on Jun 12, 2002 at 13:20 UTC
    Thanks You Guys

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://173801]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2015-07-08 03:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls