Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: Perl Directory file extension stats.

by 2teez (Priest)
on Apr 16, 2014 at 19:45 UTC ( #1082549=note: print w/ replies, xml ) Need Help??

in reply to Re^2: Perl Directory file extension stats.
in thread Perl Directory file extension stats.

You mean something like this, using hash to get all the statistics you need:

use warnings; use strict; use File::Find qw(find); use Data::Dumper; # don't fix the directory my $start_dir = $ARGV[0] || '.'; my $ext = qr[\.[^.]+]; find( \&finder => $start_dir ); my %file; # hash to collect statistics sub finder { return if $_ eq '.'; if (/($ext)/) { my $size = -s; $file{$1}++; $file{size}{$1} += $size; } } { local $Data::Dumper::Sortkeys = 1; print Dumper \%file; }

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Comment on Re^3: Perl Directory file extension stats.
Download Code
Replies are listed 'Best First'.
Re^4: Perl Directory file extension stats.
by sidsinha (Acolyte) on Apr 17, 2014 at 09:25 UTC
    Excellent! Exactly what I wanted. THanks a lot, been learning a lot from this forum!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2015-11-30 02:25 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (756 votes), past polls