#!/usr/bin/perl -w use strict; my $time = '02:42:10'; my $ip = '192.168.201.57'; my ($ace_start_time,$ace_stop_time,$ace_user,$user); while (){ if (/\b$ip\b/){ if (/Start/){ ($ace_start_time,$ace_user) = (split/,/)[1,2]; # What I tried to use, but doesn't work since it # will grab the first start entry if ($time gt $ace_start_time){ $user = $ace_user; print "$user had $ip at this time\n"; last; } } elsif (/Stop/){ ($ace_stop_time,$ace_user) = (split/,/)[1,2]; } if ($ace_start_time && $ace_stop_time){ if ( ($time gt $ace_start_time) && ($time lt $ace_stop_time) ){ $user = $ace_user; last; } } } } } __DATA__ 10/26/2004,00:02:41,jdoe,VPN_General,10.0.218.253,Stop,3D70FA44,3559,Framed,PPP,390032,3722000,4120,5306,192.168.201.57,20824,192.168.17.252 10/26/2004,00:03:42,bsmith,VPN_General,10.0.76.203,Start,3D70FA86,,Framed,PPP,,,,,192.168.201.57,20925,192.168.17.252 10/26/2004,00:23:03,bsmith,VPN_General,10.0.76.203,Stop,3D70FA86,1161,Framed,PPP,1136608,8358544,8534,10609,192.168.201.57,20925,192.168.17.252 10/26/2004,00:23:16,syoung,VPN_General,10.0.132.222,Start,3D70FA99,,Framed,PPP,,,,,192.168.201.57,20944,192.168.17.252 10/26/2004,02:34:44,syoung,VPN_General,10.0.132.222,Stop,3D70FA99,7886,Framed,PPP,432752,497712,2888,2665,192.168.201.57,20944,192.168.17.252 10/26/2004,02:34:52,lgreen,VPN_General,10.0.202.214,Start,3D70FB46,,Framed,PPP,,,,,192.168.201.57,21153,192.168.17.252 10/26/2004,02:39:04,lgreen,VPN_General,10.0.202.214,Stop,3D70FB46,253,Framed,PPP,14848,11552,160,111,192.168.201.57,21153,192.168.17.252 10/26/2004,02:40:18,cred,VPN_General,10.0.207.7,Start,3D70FB4A,,Framed,PPP,,,,,192.168.201.57,21160,192.168.17.252