Jim,

Thanks for the updated info.  I actually received a script from another user in the 
group that was able to get the information right away.  I got the script prior to 
receiving yours.  I will send you the script if you would like to have a look.  I 
still am planning to review your script and try to apply it to the same question as 
time permits.
By the way, the report ended up with over 5000 extenstions for our management to look 
at.

This sure has been interesting!

I will let you know once I have disected and digested your script :-).

Thanks,

Craig

>>> Jim Angstadt <[EMAIL PROTECTED]> 01/18/02 03:00PM >>>

--- Craig Sharp <[EMAIL PROTECTED]> wrote:
> Jim,
> 
> Thanks for the reply.  Interesting code.  This sure
> is a learning experience :-)
> 
> I tried to run the code on win2k and received the
> following error:
> 
> Variable "@temp" will not stay shared at new.pl line
> 64.
> 
> I did change the my $dir to 'c:/' for my system.
> 
> Any ideas?
> 
> Thanks,
> 
> Craig

Hi Craig,

Yes, I got that msg also.  It does not effect the
output of the script.  Did you review the output in
mx.txt?  Did it look about right?  

Since you did it for your whole hard disk ( c:/ ) you
might have a little difficulity verifying accuracy. 
Try it for a small tree, one that you can easily
verify.  Does it look right?

You title said URGENT so I wanted to quickly get
something for you to work with.  If we've got a little
more time, then you may want to consider:

1. What about files that do not have an extension?

2. How do you want the output?  The script produces
two options for sorting.  

3. Perhaps your are not interested in some file types,
such as .tmp or .??? or whatever.  Those types can be
excluded from the process.

4. After you verify accuracy, then you can comment out
some of the stuff going to mx.txt and concentrate on
formatting to your preference.  

Oh, btw, other list members may be interested in this
topic (or not) so I have replied back to the list.
This was a quick hack so there are sure to be other
and better solutions.  Hope that's ok with you.

hth,
Jim


> 
> >>> Jim Angstadt <[EMAIL PROTECTED]> 01/17/02
> 07:50PM >>>
> 
> --- [EMAIL PROTECTED] wrote:
> > Take a look at File::Find.
> 
> Hi Craig.
> 
> Here is a little more to get you started.  
> It is certainly not complete but may help.  
> [Tested on win98se and build 521.]
> 
> Mind the line wrap.
> 
> # ----------
> # starting with a given dir, 
> # subtotal all files by extension,
> # for the dir and subordinate dirs.
> 
> use strict;
> use File::Find;
> my $dir = 'c:/_/linux/bu/apache/html/'; # CHANGE
> THIS
> #my $dir   = 'c:/_/perl/test/tee_output/';
> 
> open(MX, ">mx.txt") || die "opening mx.txt. $!";
> 
> my @f     = &get_full_path_of_files( $dir );  
> foreach (@f) { print MX "$_\n"; }
> my %sizes = &get_ext_sizes( @f );  
> 
> foreach ( keys %sizes) { 
>    print MX "$_\t", '->', "\t$sizes{$_}\n"; 
> }
> print MX "\n";
> 
> %sizes = reverse %sizes;
> foreach ( sort {$a <=> $b} keys %sizes) { 
>    print MX "$_\t", '->', "\t$sizes{$_}\n"; 
> }
> #print MX "\n";
> 
> close(MX);
> 
> # ----- just subroutines below here.
> 
> sub get_ext_sizes {
>    my @files = @_;
>    my ( $size, %exts, $ext, );
>    foreach my $file ( @files ) {
>       if ( $file =~ /.*\.(.+)?/ ) {
>          # file ext with one or more chars
>          $ext = lc $1;
>          # print " ext: $ext\n";
>          $size = (stat($file))[7];
>          # print "size: $size\n";
>          if ( defined $exts{$ext} ) { 
>             $exts{$ext} += $size; 
>          }
>          else {
>             $exts{$ext} = $size; 
>          }
>          # print "cuml: $exts{$ext}\n";
>       }
>       # elsif ( ... ) { # file ext, no chars }
>       # elsif ( ... ) { # other }
>    }
>   return %exts;
> }
> 
> 
> sub get_full_path_of_files { 
>   my @temp;           # save fullpath to array.
>   find (\&wanted, $dir );
>   sub wanted{ 
>      -f and 
>      push @temp, "$File::Find::name"
>   }
>   return sort @temp;
> }
> # ----------
> 
> ---
> Jim
> 
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/ 
> _______________________________________________
> Perl-Unix-Users mailing list. To unsubscribe go to
>
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users 
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/ 
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users


Reply via email to