Eli-Sko has asked for the wisdom of the Perl Monks concerning the following question:
My perl 5.8.8 on SunOS' version of perldata claims:
All functions that are capable of creating filehandles (...) automatically create an anonymous filehandle if the handle passed to them is an uninitialized scalar variable.Imagine, if you will, my consternation at encountering the following error:
Use of uninitialized value at releases.pl line 63. Can't use an undefined value as filehandle reference at releases.pl li +ne 63.
sub RLS_ropen($) { (@_ == 1) || die "RLS_ropen called w/ invalid argument list: ".sca +lar(@_)." params instead of 1"; my $name = $_[0]; unless ( $name ) { # invalid - null or empty file name return ""; } unless ( -e $name && -r $name ) { # file doesn't exits or is unreadable return ""; } open( my $dbh, "< $name"); return $dbh; } # end RLS_ropen
Please, someone, anyone, unperplex me!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Uninitialized filehandles not as advertised?!
by almut (Canon) on May 26, 2008 at 16:45 UTC | |
by Eli-Sko (Novice) on May 27, 2008 at 06:43 UTC | |
|
Re: Uninitialized filehandles not as advertised?!
by Corion (Patriarch) on May 26, 2008 at 16:39 UTC | |
by Eli-Sko (Novice) on May 27, 2008 at 06:38 UTC | |
|
Re: Uninitialized filehandles not as advertised?!
by ikegami (Patriarch) on May 26, 2008 at 19:24 UTC | |
by Anonymous Monk on May 26, 2008 at 19:59 UTC | |
by ikegami (Patriarch) on May 26, 2008 at 20:42 UTC | |
by Eli-Sko (Novice) on May 27, 2008 at 08:33 UTC | |
by ikegami (Patriarch) on May 27, 2008 at 09:10 UTC |