#sifts all the server logs based on media type use strict; my ($type, $server,$out,$in,@input,$total,$kbytes,$mbytes); my @servers=('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','aa','bb','cc','dd','ee','ff','gg','hh','ii','jj','kk','ll','mm','nn','oo','pp'); my $dir1='//worksatation/share/dir/'; my @types=('mp3','avi','mpg','mpe','wav','mov','rmj','zip','exe','wma'); foreach $type (@types){ $total=0; open OUT, ">$dir1/sifted/$type\.txt" or die "Cannot open $out for write :$!"; foreach $server (@servers){ $in="$dir1/$server\.txt"; open IN,"$in" or next; @input=; chomp @input; foreach (@input){ if (/\.$type$/i){ $kbytes = (stat)[7]/1024; $total+=$kbytes; print OUT "$_\t$kbytes KB\n"; } } close IN; } $mbytes=$total/1024; print OUT "\n\nTotal: $mbytes MB\n"; close OUT; print "Finished $type...\n"; }