Hello, yes, you were right. normally I use anonymus foreach, thats why I just wrote chomp and didnt realize the problem. Thank you very much!
2011/3/28 Michael Ludwig <[email protected]>: > Claus Kick schrieb am 28.03.2011 um 21:36 (+0200): >> 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 > > You should have the following at the beginning of your script: > > use strict; > use warnings; > >> use Data::Dumper; >> >> my $list = "importe.properties"; >> my @directories; >> >> my $file_types = ("bat|cfg|cmd|properties|pl|xml|xsl|xslt"); > > This variable is never used. > >> open (FILE, "<".$list) or die "cannot open file"; >> @directories = <FILE>; >> close (FILE); > > chomp @directories; > >> my @files; > > Delete the above. > >> foreach my $dir (@directories) >> { >> @files = undef; > > Replace the above with: > > my @files; > >> chomp; > > You're chomping $_, but your data is in $dir. This is your bug. I'd say > it happened because you didn't chomp your data straight away, instead > leaving it in an unusable state requiring further action. > >> $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. > > There should be the dir name (containing the newline) on the preceding > line. > > -- > Michael Ludwig > _______________________________________________ > ActivePerl mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
