#sifts all the server logs based on media type @servers=('XXXXX','YYYYYYY','ZZZZZZZ'); $dir1='//workstation/share/directory/'; @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]/1000; #GETS THE 9TH ELEMENT OF file STAT - THE SIZE IN BYTES $total=$total+$kbytes; print OUT "$_\t$kbytes KB\n"; } } close $in; } $mbytes=$total/1000; print OUT "\n\nTotal: $mbytes MB\n"; close $out; print "Finished $type...\n"; }