Solved

Log analysis?

Posted on 2002-07-22
2
141 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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Uploading Binary Data using Perl 5 70
perl search and replace 6 160
cpan issue 1 55
Vb script to unzip a files and rename the files 12 69
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now