Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Parsing Logs

by johngg (Abbot)
on Oct 05, 2012 at 18:14 UTC ( #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.



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997527]
Discipulus sometimes i'm here alone with you, bony brother
[Discipulus]: ok a Perl one: how approach the task of getting all distinct paths from the edge to a node of a pascal triangle (nobackwards)?
[Discipulus]: each node has 2 descendants only: can i just compose hash keys usinng coords?
[karlgoethebier]: Discipulus: you shouldn't smoke turkish spices before noon
[Discipulus]: karl you says the same of my mom: in your place I'd been
[Discipulus]: preoccupied.. ;=)
Discipulus stopped with turkisk spices anyway.. but better hashes than arrays!

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2018-03-19 10:55 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (239 votes). Check out past polls.