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 :)