Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assistance i'm looking for

Status
Not open for further replies.

77920

Technical User
Mar 8, 2012
4
0
0
CA
I am trying to get certain information from .LOG files
currently running this which when i execute it to CMD it spams my screen of everything it reads from the array.

#!/usr/bin/perl
use strict;

open(MYINPUTFILE, "<03290232.LOG");# open for input
my(@lines) = <MYINPUTFILE>; # read file into list
@lines = sort(@lines); # sort the list
my($line);
foreach $line (@lines) # loop thru list
{ print "$line"; # print in sort order
}
close(MYINPUTFILE);

attached is the file i'm looking to grab specific text from but i'm not 100% sure how to go about doing it... I've read alot about scalars and parsing text and arrays to output files etc.

But what i want to do is create an output.txt file
that stores the specific text onto it.

PeopleNet PACOS event from device ####: Trip: ######### arrived at stop 1

General Processing .....
General Driver:
General Invalid PACOS Event

as well as the date.
 
Of course it spams your screen with the entire contents... that's exactly what you're telling it to do?

So... if I understand your requirements... you only want to print the General Processing / Driver / etc. messages that immediately follow each "PACOS event from device"?

If so, then sorting the file is a bad idea... because you have many lines with similar timestamps which may be rearranged by the sort; and in any case the file appears on cursory examination to be sorted already?

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top