...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.

-OzzyOsbourne


In reply to I have Wma file jammed in my regex by OzzyOsbourne

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.