...And it hurts me terribly
I wrote a script a while back that goes out to all my servers and logs various media files to text files, one file per server. I wrote this script at the same time to sort those server files by media type. Recently added .wma files to the mix.
Most of the file types take a minute or less to complete, with the exception of WMA which can take 20 minutes. the wma log is never bigger than the other logs, so I don't understand the time difference unless there is something going in the regex that I just don't see.
I'll be reading up on this, but...
Anyone have any ideas?
#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=<IN>; chomp @input; foreach (@input){ if (/\.$type/i){ $kbytes = (stat)[7]/1000; #GETS THE 9TH ELEMENT OF fil +e 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"; }
Thanks again, everyone.
In reply to I have Wma file jammed in my regex by OzzyOsbourne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |