#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
my $msg = <<'MSGEND';
14-OCT-2009 05:46:42 * (CONNECT_DATA=(SID=fgs)(CID=(PROGRAM=sqlplus@mtdb)(HOST=mtdb_a)(USER=root))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.60.4.2)(PORT=34898)) * establish * fgs * 0
MSGEND
print "msg: $msg\n";
# Isolate content of tags
if ($msg =~ m{(.*)})
{
my $txt = $1;
print "txt: $txt\n";
# Find the date
if ($txt =~ /(\d{2}-\w+-\d{4})\s+(\d{2}:\d{2}:\d{2})/)
{
my ($date, $time) = ($1, $2);
print "date: $date\n";
print "time: $time\n";
}
# Find the host (IP address, not name)
if ($txt =~ /HOST=([\d\.]+)/)
{
my $host = $1;
print "host: $host\n";
}
}