in reply to Re: Pattern Matching in Cygwin Perl vs. Win32 Perl
in thread Pattern Matching in Cygwin Perl vs. Win32 Perl

Also, leave the newline ending off the end of the die() statement. It supressses line number information. According to perlfunc, die:

If the last element of LIST does not end in a newline, the current script line number and input line number (if any) are also printed, and a newline is supplied.

Here is my favorite file opener. I have used it for a couple of years and used to routinely catch a lot of wierd errors due to my typing skills (or lack there of).

open my $fh, '<', $filename or die qq{Cannot open "$filename": $!}; open my $fh, '>', $filename or die qq{Cannot open "$filename": $!}; open my $fh, '>>', $filename or die qq{Cannot open "$filename": $!};
HTH,
Charles

Replies are listed 'Best First'.
Re^3: Pattern Matching in Cygwin Perl vs. Win32 Perl
by ikegami (Patriarch) on Aug 27, 2008 at 04:14 UTC

    I disagree completely with your first point. If you need to know on what line an I/O error occured, something is horribly wrong with your error handling. Users must not have to dig into a program to find and address the cause of errors under their control (as opposed to a programming error).

    I agree with the other changes, but I didn't want to venture far from the topic until the OP's problem became known. How I write it:

    open(my $fh_log, '>>', $qfn_log) or die(qq{Cannot open log file "$qfn_log": $!\n});