OzzyOsbourne has asked for the wisdom of the Perl Monks concerning the following question:
...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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 1: I have Wma file jammed in my regex
by tilly (Archbishop) on Jan 19, 2001 at 19:27 UTC | |
by PiEquals3 (Acolyte) on Jan 19, 2001 at 23:31 UTC | |
by myocom (Deacon) on Jan 19, 2001 at 23:43 UTC | |
|
Re: I have Wma file jammed in my regex
by Trimbach (Curate) on Jan 19, 2001 at 18:57 UTC | |
|
Re: I have Wma file jammed in my regex
by ChOas (Curate) on Jan 19, 2001 at 18:41 UTC | |
|
Re: I have Wma file jammed in my regex
by OzzyOsbourne (Chaplain) on Jan 19, 2001 at 21:23 UTC | |
by Ovid (Cardinal) on Jan 19, 2001 at 21:34 UTC |