On Thursday 28 Oct 2010 06:30:01 Mike Blezien wrote: > Hello, > > I've been out of the programming game for a while and recently got back > into some small programming projects. Just need to figure out if there is > a Perl function to determine the total size of a folder and files? Meaning > once we open/read a directory is to calculate the total, in MB's, the size > of the files in a particular directory folder. > > Thanks, > > > Mike(mickalo)Blezien > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > Thunder Rain Internet Publishing > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Hi Mike, You could make use of File::Find's find function along with stat. =pod Example use strict; use warnings; use File::Find; my $size; my $directory = '/path/to/some/directory'; sub determine_size { if ( -f $File::Find::name ) { $size += ( stat $File::Find::name )[7]; } } find( \&determine_size, $directory ); $size /= 1024 * 1024; print "Total size: $size MB\n"; =cut Relevant documents to read: `perldoc File::Find` - http://perldoc.perl.org/File/Find.html `perldoc -f stat` - http://perldoc.perl.org/functions/stat.html Regards, Alan Haggai Alavi. -- The difference makes the difference. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/