diff options
author | jluehrs2 <jluehrs2@uiuc.edu> | 2008-02-02 18:49:30 -0500 |
---|---|---|
committer | jluehrs2 <jluehrs2@uiuc.edu> | 2008-02-02 18:49:30 -0500 |
commit | bc56283023a7256419ae5ed8aefa8611fd45b94e (patch) | |
tree | 82885f3ba0f327139b50595cf2db89d831a5263c | |
parent | 4400ff6be8c3e149ba427718f55ebb2ef48183e5 (diff) | |
download | games-word-bc56283023a7256419ae5ed8aefa8611fd45b94e.tar.gz games-word-bc56283023a7256419ae5ed8aefa8611fd45b94e.zip |
make sure we test all open()s for failure
-rw-r--r-- | lib/Games/Word/Wordlist.pm | 8 |
1 files 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($_); |