develooper Front page | perl.perl5.porters | Postings from March 2007

chdir with file and directory handles

Thread Next
From:
Nicholas Clark
Date:
March 9, 2007 08:36
Subject:
chdir with file and directory handles
Message ID:
20070309163544.GS5748@plum.flirble.org
use Cwd;

opendir D, "t" or die $!;
open D, "ext" or die $!;
chdir D or die $!;

print getcwd, "\n";
__END__


Where do you think we end up?

/home/nick/p4perl/perl/ext

I'm not sure that this is logical. And for a variant:

use Cwd;

opendir D, "t" or die $!;
open D, "MANIFEST" or die $!;
chdir D or die $!;

print getcwd, "\n";
__END__

Not a directory at chdir.pl line 5.


Surely we should be taking the dir handle in preference to the file handle for
the ambiguous case?

Nicholas Clark

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About