in reply to How to parse the logs in a generic manner
Write a module:
package Vasuperl; use strict; use warnings; use Exporter; use vars qw($VERSION @ISA @EXPORT_OK ); $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT_OK = qw(parse_log); sub parse_log { my ( $log_file, $pattern ) = @_; # parse your log # and return something useful } 1;
Use it:
#!/usr/bin/env perl use strict; use warnings; use lib q(.); use Vasuperl qw (parse_log); my $log_file = shift || die $!; my $pattern = qr(.); my $result = parse_log( $log_file, $pattern ); # do something with $result __END__
Update: Changed legacy code on special request by choroba:
package Vasuperl; use strict; use warnings; use Exporter qw(import); our ( $VERSION, @EXPORT_OK ); $VERSION = 1.01; @EXPORT_OK = qw(parse_log); sub parse_log { my ( $log_file, $pattern ) = @_; # parse your log # and return something useful + } 1;
What is so difficult with this that you can't figure it out your self?
Karl
«The Crux of the Biscuit is the Apostrophe»
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to parse the logs in a generic manner
by choroba (Cardinal) on Jan 02, 2015 at 17:12 UTC | |
by karlgoethebier (Abbot) on Jan 02, 2015 at 18:38 UTC |