From bc56283023a7256419ae5ed8aefa8611fd45b94e Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Sat, 2 Feb 2008 18:49:30 -0500 Subject: make sure we test all open()s for failure --- lib/Games/Word/Wordlist.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Games/Word/Wordlist.pm b/lib/Games/Word/Wordlist.pm index 107b85f..28607fd 100644 --- a/lib/Games/Word/Wordlist.pm +++ b/lib/Games/Word/Wordlist.pm @@ -152,7 +152,7 @@ sub words { my $self = shift; return @{$self->{word_list}} if $self->{cache}; - open my $fh, '<', $self->{file}; + open my $fh, '<', $self->{file} or die "Opening $self->{file} failed"; for (<$fh>) {} return $.; } @@ -220,8 +220,7 @@ sub _is_word_nocache { my $self = shift; my $word = shift; - open my $fh, '<', $self->{file} - or die "Couldn't open word list: $self->{file}"; + open my $fh, '<', $self->{file} or die "Opening $self->{file} failed"; while (<$fh>) { chomp; return 1 if $_ eq $word; @@ -260,8 +259,7 @@ sub _each_word_nocache { my $self = shift; my $code = shift; - open my $fh, '<', $self->{file} - or die "Couldn't open word list: $self->{file}"; + open my $fh, '<', $self->{file} or die "Opening $self->{file} failed"; while (<$fh>) { chomp; &$code($_); -- cgit v1.2.3-54-g00ecf