Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Parsing Logs

by johngg (Canon)
on Oct 05, 2012 at 18:14 UTC ( [id://997527]=note: print w/replies, xml ) Need Help??


in reply to Parsing Logs

You can also save some typing where you build your @array from the MSG file handle. Your

foreach $line (<MSG>) { chomp($line); push(@array, $line);

could be written

chomp( @array = <MSG> );

It is good practice to put

use strict; use warnings;

at the top of your scripts to enforce a little coding discipline and catch typos. It is also good practice to use lexical file handles, the three-argument form of open and to check that it succeeded (you do this), but also give the o/s error (see $! in perlvar) to give a better idea of why it failed.

open my $msgFH, q{<}, q{/some/file} or die qq{open: < /some/file: $!\n};

I hope these points are helpful.

Cheers,

JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://997527]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-03-29 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found