B
Ben Burch
Why did I know somebody was going to object if I didn't make my hack
into a textbook example?
Nope. Perl programmers are fond of their one-liners, but they are
unclear and missed in peer code inspections.
Much better is;
my $status = open (EXCLUDE, '<', $file2);
if( !$status )
{
print "File open error $!";
exit 1;
}
(You can die() if you want to, but no reason to do it unless you plan
to handle the signal...)
And there is no reason to make the FHs in scalar form at all, and its
less clear when you do.
Unless is an abomination when it comes to code that will have faults
found in code review.
Sure, run it through tidy and get some white space if you like, I never
have any trouble reading it without.
into a textbook example?
Tad J said:use warnings;
use strict;
You should always, yes *always*, check the return value from open():
open my $EXCLUDE, '<', $file2 or die "could not open '$file2' $!";
Nope. Perl programmers are fond of their one-liners, but they are
unclear and missed in peer code inspections.
Much better is;
my $status = open (EXCLUDE, '<', $file2);
if( !$status )
{
print "File open error $!";
exit 1;
}
(You can die() if you want to, but no reason to do it unless you plan
to handle the signal...)
And there is no reason to make the FHs in scalar form at all, and its
less clear when you do.
unless ( exists $exclude{$line} )
Unless is an abomination when it comes to code that will have faults
found in code review.
or at least make wise use of whitespace and punctuation:
if ( ! exists $exclude{$line} )
Sure, run it through tidy and get some white space if you like, I never
have any trouble reading it without.