in reply to Re^4: "readdir() attempted on invalid dirhandle" error?
in thread "readdir() attempted on invalid dirhandle" error?
Except open and opendir doesn't let you use both slots anymore.
$ usr/perlbrew/perls/5.10t/bin/perl -Mv5.10 -e' open FOO, "<", ".bashrc" or die $!; opendir FOO, "." or die $!; print "File: ", scalar( <FOO> ); say "Dir: ", scalar( readdir( FOO ) ); ' File: # If not running interactively, don't do anything Dir: .gitconfig $ usr/perlbrew/perls/5.10t/bin/perl -Mv5.10 -we' open FOO, "<", ".bashrc" or die $!; opendir FOO, "." or die $!; print "File: ", scalar( <FOO> ); say "Dir: ", scalar( readdir( FOO ) ); ' Opening filehandle FOO also as a directory at -e line 3. File: # If not running interactively, don't do anything Dir: .gitconfig $ usr/perlbrew/perls/5.12t/bin/perl -Mv5.10 -e' open FOO, "<", ".bashrc" or die $!; opendir FOO, "." or die $!; print "File: ", scalar( <FOO> ); say "Dir: ", scalar( readdir( FOO ) ); ' Opening filehandle FOO also as a directory at -e line 3. File: # If not running interactively, don't do anything Dir: .gitconfig $ usr/perlbrew/perls/5.24t/bin/perl -Mv5.10 -e' open FOO, "<", ".bashrc" or die $!; opendir FOO, "." or die $!; print "File: ", scalar( <FOO> ); say "Dir: ", scalar( readdir( FOO ) ); ' Opening filehandle FOO also as a directory at -e line 3. File: # If not running interactively, don't do anything Dir: .python_history $ usr/perlbrew/perls/5.26t/bin/perl -Mv5.10 -e' open FOO, "<", ".bashrc" or die $!; opendir FOO, "." or die $!; print "File: ", scalar( <FOO> ); say "Dir: ", scalar( readdir( FOO ) ); ' Opening filehandle FOO also as a directory. This will be a fatal error + in Perl 5.28 at -e line 3. File: # If not running interactively, don't do anything Dir: .gitconfig $ usr/perlbrew/perls/5.28t/bin/perl -Mv5.10 -e' open FOO, "<", ".bashrc" or die $!; opendir FOO, "." or die $!; print "File: ", scalar( <FOO> ); say "Dir: ", scalar( readdir( FOO ) ); ' Cannot open FOO as a dirhandle: it is already open as a filehandle at +-e line 3.
5.10: Warns when warnings enabled.
5.12: Warns by default.
5.26: "This will be a fatal error in Perl 5.28" to the warning.
5.28: Fatal.
|
|---|