GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Algorithm::Accounting(3) User Contributed Perl Documentation Algorithm::Accounting(3)

  Algorithm::Accounting - Generate accounting statistic for general logs

  my $fields = [qw/id author file date/];
  my $groups = [[qw(author file)], [qw(author date)]];
  my $data = [
        [1, 'alice', '/foo.txt', '2004-05-01' ],
        [2, 'bob',   '/foo.txt', '2004-05-03' ],
        [3, 'alice', '/foo.txt', '2004-05-04' ],
        [4, 'john ', '/foo.txt', '2004-05-04' ],
        [5, 'john ', [qw(/foo.txt /bar.txt], '2004-05-04' ],
  ];


  # give the object information
  my $acc = Algorithm::Accounting->new(fields => $fields,
                                       field_groups => $groups );

  $acc->append_data($data);

  # Generate report to STDOUT
  $acc->report;

  # Get result
  my $result = $acc->result;

  # Get result of a specific field.
  my $author_accounting = $acc->result('author');

  # Reset current result so we can restart
  $acc->reset;

"Algorithm::Accounting" provide simple aggregation method to make log accounting easier. It accepts data in rows, each rows can have many fields, and each field is a scalar or a list(arrayref).

The basic usage is you walk through all your logs, and use append_data() to insert each rows, (you'll have to split the line into fields), and then call result() to retrieve the result, or report() to immediatly see simple result.

You may specify a filed_groups parameter (arrayref of arrayref), and "Algorithm::Accounting" will account these fields in groups.

Notice you'll have to give a list fileds first, the append_data() depends on the number of fields to work properly.

Copyright 2004 by Kang-min Liu <gugod@gugod.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See <http://www.perl.com/perl/misc/Artistic.html>

2005-01-23 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.