Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Log analysis?

Posted on 2002-07-22
2
Medium Priority
?
184 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 300 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Six Sigma Control Plans

722 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