Alright, perhaps try something along these lines:
#! /usr/bin/perl
use strict;
use warnings;
my $file = shift @ARGV;
my @times = map { /(\d+)_seconds/; $1 }
grep { /$file/ } <DATA>;
my $totaltime; $totaltime += $_ for @times;
my $avgtime = $totaltime / @times;
print "Average time: $avgtime\n\n";
__DATA__
[24/Mar/2004:12:26:52 /manual/misc/perf-tuning.html 0_seconds
[24/Mar/2004:12:27:33 /manual/mod/mod_status.html 0_seconds
[24/Mar/2004:12:27:39 /manual/mod/module-dict.html 0_seconds
[24/Mar/2004:12:27:46 /manual/misc/rewriteguide.html 0_seconds
[24/Mar/2004:12:27:53 /manual/mod/mod_rewrite.html 5_seconds
[24/Mar/2004:12:27:53 /manual/images/mod_rewrite_fig1.gif 0_seconds
[24/Mar/2004:12:27:53 /manual/images/mod_rewrite_fig2.gif 0_seconds
[24/Mar/2004:12:28:05 /manual/new_features_1_3.html 0_seconds
[24/Mar/2004:12:29:53 /manual/mod/mod_rewrite.html 6_seconds
[24/Mar/2004:12:29:54 /manual/mod/mod_rewrite.html 7_seconds
[24/Mar/2004:12:29:55 /manual/mod/mod_rewrite.html 8_seconds
[24/Mar/2004:12:29:56 /manual/mod/mod_rewrite.html 9_seconds
I still think you should try the format manipulation in Perl, though; it's easy to do, and you'll only have one script to maintain.
_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
--Friedrich Nietzsche
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|