This takes too long to process. Please tell me how can this be optimised.
Below is the sample lines attached.
99.60.97.205 - - [26/Mar/2011:06:00:00 +0000] GET /2
+009-03-29/world/impact.row.atlantic_1_rower-paul-ridley-cancer-resear
+ch?_s=PM:WORLD HTTP/1.1 200 9386 www.abc.com Mozilla/
+5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.13 (
+KHTML, like Gecko) Chrome/9.0.597.107 Safari/534.13 TCP_MISS
+ Apache=- - 1068000 - - - deflate
+=- rmt=-
72.234.67.132 - - [26/Mar/2011:09:00:00 +0000] GET /a
+d-abc.php?f=medium_rectangle HTTP/1.1 200 869 www.abc.com
+ Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.
+16) Gecko/20101130 Firefox/3.5.16 TCP_HIT Apache=- -
+ 1000 - - - deflate=- rmt=-
68.12.178.167 - - [26/Mar/2011:09:00:00 +0000] GET /a
+d-feedback.js.php?e3e999d9b79cf36c165f5b379a0e9f269be82344 HTTP/1.1
+ 200 600 www.abc.com Mozilla/4.0 (compatible; MSIE 8.
+0; Windows NT 5.1; Trident/4.0; GTB6.6; .NET CLR 2.0.50727; .NET CLR
+3.0.4506.2152; .NET CLR 3.5.30729) TCP_HIT Apache=- - 10
+00 - - - deflate=- rmt=-
The file size is 16955714940 bytes.
#!/usr/bin/perl
use strict;
use warnings;
use Date::Manip;
my $n="4";
my $date_converted = UnixDate(ParseDate("$n days ago"),"%e/%h/%Y");
open FILE,"> file.txt";
open DATA,"input.txt";
while(<DATA>){
my @tab_delimited_array = split(/\t/,$_);
$tab_delimited_array[3] =~ s/^\[//;
$tab_delimited_array[3] =~ s/^\-//;
my $converted_date = Date_ConvTZ( UnixDate($tab_delimited_arra
+y[3],"%Y%m%d%H:%M:%S"),'GMT','PST');
my $pst_converted_date = UnixDate($converted_date,"%e/%h/%Y:%H
+:%M:%S");
$pst_converted_date =~ s/^\s//g;
my $extracted_YMD=UnixDate($converted_date,"%e/%h/%Y");
if($extracted_YMD =~ m/$date_converted/){
print FILE $_;
}
}
close FILE;
close DATA;
-
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.