Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Log File Parsing using "split"

by ruzam (Curate)
on May 19, 2006 at 17:23 UTC ( [id://550546]=note: print w/replies, xml ) Need Help??


in reply to Log File Parsing using "split"

Suggestions:

Provide more information with $! when open fails (you'll apreciate it when it happens).
open (LOGFILE, "< $logfile") or die ("Could not open $logfile: $!");
You're kind of care free when mixing $thiscust with record fields, hash keys and file handles. Maybe something more like this:
$thiscust = (split /\//, $fields[4])[1]; if ( ! $cust{$thiscust} ) { print "customer $thiscust\n"; $cust{$thiscust} = $thiscust; open (my $fh, ">> ${prefix}${thiscust}${suffix}") or die ("Cannot open ${prefix}${thiscust}${suffix}: $!"); $cust{$thiscust} = $fh; } my $fh = $cust{$thiscust}; print $fh $_;

Replies are listed 'Best First'.
Re^2: Log File Parsing using "split"
by nobull (Friar) on May 20, 2006 at 11:43 UTC
    open (my $fh, ">> ${prefix}${thiscust}${suffix}")
    Why do you concatenate the second and third arguments to open() into a string just so that perl can pull it appart again?

    open (my $fh, '>>', "$prefix$thiscust$suffix")
      Old Habit :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-19 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found