>Claus Kick writes:
>
>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 strict;
use warnings;

>use Data::Dumper;
>
>my $list = "importe.properties";

No need to pre-declare directories - see below

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

use lexical file handles & three argument form of open
open (FILE, "<", $list) or die "cannot open file: $^E";

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

my @directories = <FILE>;
>@directories = <FILE>;
>close (FILE);
>

No need to preclare @files - see below
>my @files;
>
>foreach my $dir (@directories)
>{

        No need to set @files - see below
>       @files = undef;

        This is your problem. You are chomping $_; not $dir

        chomp $dir;
>       chomp;

        Change for readability

        $dir =~ s{\\} {/}g;
>       $dir =~ s/\\/\//g;
>       #if ($dir =~ /[A-Z]{1}:(.+)/)
>       #{
>       #       $dir = $1;
>       #}
>       print "DIR: ".$dir."\n";
>       opendir(DIR, $dir) or die "cannot open directory: $dir - $!";

        my @files = readdir(DIR);

>       @files = readdir(DIR);
>       closedir(DIR);
>       print Dumper \@files;
>}
>

HTH,
Ken Slater




_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to