Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directory access on windows

Status
Not open for further replies.

weirdcpu

IS-IT--Management
Mar 19, 2005
22
FR
hello,

Is there specific commands or parameters to use when accessing a directory on Windows ?

This is my script :

#use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::purity=1;

my $base="C:\\Epusbdrv";
print "base ".$base."\n";
push(@CDROM, scrute( $base ) );
print Dumper( @CDROM );
foreach $elt ( @CDROM )
{
print ($elt."\n" );
}
sub scrute {

my $rep = shift @_;
print "shift ".$rep."\n";
my $lst;
my @replst;
open REPHDL, $rep or die "rep $rep inacessible : $!" ;
@replst = readdir REPHDL;
close REPHDL;
print @replst;
foreach $elt ( @replst )
{
print $elt;
push( @lst, $elt ) if -f $elt;
foreach $toto (@lst )
{
print $toto "\n";
}
my $subdir = $rep."\\".$elt;
push( @lst, scrute( $subdir)) if -d $elt;
}
return @lst;

}
For now the opendir don't accept to open C:\Epusbdrv.
The script return :

E:\Perl>perl essai1.pl
base C:\Epusbdrv
shift C:\Epusbdrv
rep C:\Epusbdrv inacessible : Permission denied at essai1.pl line 20.

E:\Perl>

I know the directory which i try to read is not on the same disk that the perl directory. But C:\Epusbdrv hasn't restrictive permission.
Should i specify the hard disk unit or the path by a special ActivePerl function ?

Thanks for your help
 
shouldn't you be using opendir() instead of open()

Code:
[b]opendir[/b] REPHDL, $rep or die "rep $rep inacessible : $!"  ;

open() is to open files
 
What can i say ?

Where was my brain when i tested it ? :-D

Thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top