Solved

Log analysis?

Posted on 2002-07-22
2
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Six Sigma Control Plans

630 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