in reply to Uninitialized filehandles not as advertised?!
Since open already checks if the file exists and if it's readable, your sub would be better written as
sub RLS_ropen($) { my ($name) = @_; defined($name) or die "A file name must be supplied to RLS_ropen\n"; open(my $dbh, '<', $name) or return ''; return $dbh; } # end RLS_ropen
And it begs the question... Why do you need a sub at all? All there is in it is the call to open
Returning undef would be better than returning an empty string.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Uninitialized filehandles not as advertised?!
by Anonymous Monk on May 26, 2008 at 19:59 UTC | |
by ikegami (Patriarch) on May 26, 2008 at 20:42 UTC | |
|
Re^2: Uninitialized filehandles not as advertised?!
by Eli-Sko (Novice) on May 27, 2008 at 08:33 UTC | |
by ikegami (Patriarch) on May 27, 2008 at 09:10 UTC |