in reply to Re^2: search and extract lines which contain a word
in thread search and extract lines which contain a word
print "Specify full directory of logfile.\n"; $file = <STDIN>; chomp $file; print "\nIdentified file is $file\n"; print "Is this correct? (y/n)\n"; $confirm = <STDIN>; chomp $confirm; if ($confirm eq "y") { print "\nCommencing work on $file.\n"; workings(); } else { print "Terminating program...\n"; } ## Subroutine to open & read logfile sub workings { print"In Subroutine workings now.\n"; open (LOGFILE, $file); print "Opening logfile...\n"; open (OUT, ">>", 'D:\Temp\test.txt') or die "$!"; print "Opening output file...\n"; print "Checking for string GATEWAY...\n"; while (<LOGFILE>) { if (/gateway/) { $count = $count + 1; print OUT; print "Extracting line ...\n"; } elsif (/TIMESTAMP/) { $count = $count + 1; print OUT; print "Extracting line ...\n"; } } print "\nTotal of $count lines extracted.\n"; close OUT; close LOGFILE; } ##Array to contain usernames @names = qw(mddinzam khairulz sawaikha caoyx jchew khamshae hartinib t +eev xiaolh yettynm yussofyu leegm narayam karuppa doraira edanor raza +liha sambanr jwong lamks linwb rashid ongsp ooisc mohdrosn);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: search and extract lines which contain a word
by ikegami (Patriarch) on Mar 27, 2008 at 11:36 UTC |