Solved

Log analysis?

Posted on 2002-07-22
2
160 Views
Last Modified: 2010-03-05
Hi.

I have this problem with perl. I'm trying to read through a textfile. What I'm trying to do is extract some things from this textfile. Unfortunatly the file's rows are different in the number of words and stuff.
I'm trying to do something like this:
foreach $row (<FH>) {
($machine, $volume, $number) = ($row =~ /(\w{8}) (\/\S{3}\d{3}) \[start=(\d)]\/);

This doesn't seem to work though. I get "Syntax OK" when I do a perl -cw on the script but a "Use of uninitialised value" when I run it. Extracting the data one by one seems to work though. Anyone feel like telling me what I do wrong or perhaps point me to a good tutorial about this?
I looked at http://www.unixreview.com/documents/s=7458/uni1025636070823/0207e.htm
and the documentation on perldoc.com but didn't get any wiser.
What I'm trying to do (in case it isn't clear) is extract 3 fields from a string and put them in some variables for further manipulation.

wbr

.haeger
0
Comment
Question by:haeger
2 Comments
 
LVL 1

Author Comment

by:haeger
ID: 7168878
Nevermind. I found it out myself.
If you want to earn 100 points though I'd appriciate some tips and tricks or links about this.

wbr

.haeger
0
 
LVL 3

Accepted Solution

by:
DVB earned 100 total points
ID: 7185531
Generic tips:
use -w
use strict;

These solve the bulk of problems that can be faced.
(And the paterns matched return as $1,$2,$3....)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question