Cannot read directory c:\test

A

alexjaquet

Hi,

I wrote a simple test script but I could not read directory entries.

Here is the code I use :

#!/usr/bin/perl -w
use strict;
use File::Copy;

my $dir_start;my $dir_dest;
print "Donner le repertoire initial \n";
$dir_start= <STDIN>;
print "Donner le repertoire de destination \n";
$dir_dest = <STDIN>;
#affichage du contenu du repertoire
opendir(DIR, $dir_start) or die "Cannot read directory $dir_start:
$!\n";c:
my @listarray = readdir(DIR);
close (DIR);
foreach my $f (@listarray) {
print "$f \n";
}
print "Donner le nom fichier a copier\n";
my $file_to_move = <STDIN>;
if (-e $dir_dest/$file_to_move) { rename
($dir_dest/$file_to_move,"$dir_dest/$file_to_move.old");}
copy("$dir_start","$dir_dest/$file_to_move");
 
A

A. Sinan Unur

(e-mail address removed) wrote in @o13g2000cwo.googlegroups.com:

[ Hmmm ... so you get out of my killfile by changing your posting
address. ]
I wrote a simple test script but I could not read directory entries.

Here is the code I use :

#!/usr/bin/perl -w
use strict;
use File::Copy;

my $dir_start;my $dir_dest;
print "Donner le repertoire initial \n";
$dir_start= <STDIN>;

Oh, for heaven's sake, you have been at this long enough to know that
you need to chomp that string.

Sinan

PS: Bye.
 
T

Tad McClellan

$dir_start= <STDIN>;
opendir(DIR, $dir_start) or die "Cannot read directory $dir_start:
$!\n";c:


If you get in the habit of properly formatting your diagnostic
messages, you will never be mystified by this problem again.

opendir(DIR, $dir_start) or
die "Cannot read directory '$dir_start' $!\n";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top