[perl #21672] IO::New and undefined filename behaviour
[p5sagit/p5-mst-13.2.git] / ext / IO / lib / IO / File.pm
index 240033f..9c4177a 100644 (file)
@@ -51,7 +51,7 @@ these classes with methods that are specific to file handles.
 
 =item new ( FILENAME [,MODE [,PERMS]] )
 
-Creates a C<IO::File>.  If it receives any parameters, they are passed to
+Creates an C<IO::File>.  If it receives any parameters, they are passed to
 the method C<open>; if the open fails, the object is destroyed.  Otherwise,
 it is returned to the caller.
 
@@ -78,7 +78,7 @@ whitespace or other special characters, and the second parameter is
 the open mode, optionally followed by a file permission value.
 
 If C<IO::File::open> receives a Perl mode string ("E<gt>", "+E<lt>", etc.)
-or a ANSI C fopen() mode string ("w", "r+", etc.), it uses the basic
+or an ANSI C fopen() mode string ("w", "r+", etc.), it uses the basic
 Perl C<open> operator (but protects any special characters).
 
 If C<IO::File::open> is given a numeric mode, it passes that mode
@@ -158,9 +158,11 @@ sub open {
            defined $perms or $perms = 0666;
            return sysopen($fh, $file, $mode, $perms);
        }
-       if (! File::Spec->file_name_is_absolute($file)) {
-            $file = File::Spec->catfile(File::Spec->curdir(),$file);
-        }
+       if (defined($file) && length($file)
+           && ! File::Spec->file_name_is_absolute($file))
+       {
+           $file = File::Spec->catfile(File::Spec->curdir(),$file);
+       }
        $file = IO::Handle::_open_mode_string($mode) . " $file\0";
     }
     open($fh, $file);