Stupidity on my side - readdir(), chdir() ..

Claus Kick <[email protected]> Mon, 28 Mar 2011 21:36:46 +0200
Newsgroups gmane.comp.lang.perl.active-perl
Message-ID <[email protected]>
Hello all,

I am writing a small tool just to update contents of a couple of
directories. The directories are just stored in a flat text file like
this:

d:\updates\Imports\MCM_Import_CSG\Config
d:\updates\Imports\MCM_Import_CSV
[...]
f:\sap_import_prod\bin

I figured, I just leave windows notation and then switch to proper
notation before doing anything.
Well, I did not get very far.
If I do the following

use Data::Dumper;

my $list = "importe.properties";
my @directories;

my $file_types = ("bat|cfg|cmd|properties|pl|xml|xsl|xslt");

open (FILE, "<".$list) or die "cannot open file";
@directories = <FILE>;
close (FILE);

my @files;

foreach my $dir (@directories)
{
	@files = undef;
	chomp;
	$dir =~ s/\\/\//g;
	#if ($dir =~ /[A-Z]{1}:(.+)/)
	#{
	#	$dir = $1;
	#}
	print "DIR: ".$dir."\n";
	opendir(DIR, $dir) or die "cannot open directory: $dir - $!";
	@files = readdir(DIR);
	closedir(DIR);
	print Dumper \@files;
}

the script dies at the die with  - No such file or directory at
importe.pl line 50.

the directories are there, I manually copied each path from the
windows explorer address bar.
If I leave away the drive letter as in the commented out part, then I
do not find the files on the other disk.
I also tried using chdir($dir) and then chdir($Bin).
This only works for the last entry in the list, for the rest, the
script insists that cwd is still $Bin.

What am I doing wrong?

(This is perl, v5.8.8 built for MSWin32-x86-multi-thread) on Windows 2003.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs