ANNOUNCE: Apache::LogRegex 1.0

From: Peter Hickman (peter_at_semantico.com)
Date: 01/26/04

  • Next message: Peter Hickman: "ANNOUNCE: Graph::Timeline and Graph::Timeline::GD 1.0"
    Date: Mon, 26 Jan 2004 12:45:20 +0000
    
    

    Apache::LogRegex - Parse a line from an Apache logfile into a hash

    This document refers to version 1.00 of Apache::LogRegex, released
    January 22nd, 2004

       use Apache::LogRegex;

       my $lr;

       eval { $lr = Apache::LogRegex->new($log_format) };
       die "Unable to parse log line: $@" if ($@);

       my %data;

       while ( my $line_from_logfile = <> ) {
         eval { %data = $lr->parse($line_from_logfile); };
         if (%data) {
           # We have data to process
         } else {
           # We could not parse this line
         }
       }

    Designed as a simple class to parse Apache log files. It will construct
    a regex that will parse the given log file format and can then parse
    lines from the log file line by line returning a hash of each line.

    The field names of the hash are derived from the log file format. Thus
    if the format is '%a %t \"%r\" %s %b %T \"%{Referer}i\" ...' then the
    keys of the hash will be %a, %t, %r, %s, %b, %T and %{Referer}i.

    Should these key names be unusable, as I guess they probably are, then
    subclass and provide an override rename_this_name() method that can
    rename the keys before they are added in the array of field names.

    At a CPAN near you soon.


  • Next message: Peter Hickman: "ANNOUNCE: Graph::Timeline and Graph::Timeline::GD 1.0"

    Relevant Pages

    • [ANN] Apache::LogRegex 1.1 minor bugfix release
      ... Apache::LogRegex - Parse a line from an Apache logfile into a hash ... Designed as a simple class to parse Apache log files. ... The field names of the hash are derived from the log file format. ...
      (comp.lang.perl.modules)
    • ANN: Apache::LogRegex 1.2
      ... Designed as a simple class to parse Apache log files. ... lines from the log file line by line returning a hash of each line. ...
      (comp.lang.perl.modules)
    • Re: Howto conjoin information from two hash tables?
      ... After the backup by Oracle RMAN tool I parse the log file and create ... processed by the channel ... I would like to concatenate information from the above two hash tables ...
      (perl.beginners)
    • Re: Parsing file
      ... I want to parse a file with contents that looks as follows: ... While trying a similar thing for DEFINITION record, instead of appending current hash with ENTRY and NAME, the DEFINITION record replaces the contents in the hash? ... 'DEFINITION' => 'U18 small nucleolar RNA' ... spaces and split them into an array, feed the array to the hash and hop time ...
      (perl.beginners)
    • Re: Import Files to Excel File
      ... I want to parse over 300 of these into a single excel or csv file. ... Store the data extracted from the files in a hash or hash of hashes. ... data to a spreadsheet document. ...
      (perl.beginners)