Solved

Log analysis?

Posted on 2002-07-22
2
172 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

685 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