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;

In reply to Optimise the script by Anonymous Monk

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.