I don't have an answer for your question, because frankly that regex makes
my head hurt :-0

What I suggest is making something a little more reusable by actually
parsing the info istead of just grepping for what you need this particular
time.  I would do something like this...

my $log_entry = q[Jul 25 10:39:12...]; # a single log entry

my %data = ();

# grab the date from the first section,
# and remove the first section all-together
$log_entry =~ s/^(.*?:.*?:\d+).*?:.*?:.*?:/Date $1,/;

# split the line my the commas
for (split /\s*,\s*/, $log_entry) {
    # grab the name/value pairs and save to a hash
    /^(\w+)\s*(.*)/ and $data{$1} = $2 and next;
}

# grab what you need from the hash
print "DATE: $data{Date}\n";
print "PeerAddress: $data{PeerAddress}\n";
print "ConnectTime: $data{ConnectTime}\n";
print "DisconnectTime: $data{DisconnectTime}\n";
print "InfoType: $data{InfoType}\n";
# etc...

<< output for the specific log entry you gave >>
DATE: Jul 25 10:39:12
PeerAddress: 0051122323223
ConnectTime: *10:47:09.753 GMT Thu Jul 25 2002
DisconnectTime: *10:47:09.753 GMT Thu Jul 25 2002
InfoType: 2


....Anyway, just an thought, it might be easier and cleaner.

Rob

-----Original Message-----
From: Hernan Marcelo Salvarezza [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 30, 2002 8:44 AM
To: [EMAIL PROTECTED]
Subject: cisco regexp


Hello all, i am parsing a cisco log and i can'nt find the exact
regexp,following goes the log and the script..

Jul 25 10:39:12 10.0.0.1 852: 1d23h: %VOIPAAA-5-VOIP_CALL_HISTORY:
CallLegType 2, ConnectionId 0 0 0 0, SetupTime *10:46:49.143 GMT Thu Jul
25 2002, PeerAddress 0051122323223, PeerSubAddress , DisconnectCause 0
, DisconnectText , ConnectTime *10:47:09.753 GMT Thu Jul 25 2002,
DisconnectTime *10:47:09.753 GMT Thu Jul 25 2002, CallOrigin 1,
ChargedUnits 0, InfoType 2, TransmitPackets 0, TransmitBytes 0,
ReceivePackets 358, ReceiveBytes 7064
........

my $dtgT = '\d|:|\.';   
my $peer = 'PeerAddress';
my $upT = 'ConnectTime';
my $downT = 'DisconnectTime';
my $prefT = '"0051"';
<snip>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to