opendir()

A

Andrew

I'm trying to learn how to use the opendir() function with perl, and each
time I try to run my perl script I keep getting "Permission denied".

Here is the script:


open (DIR, "c:\\Temp\\Directory1") or die "Can't open the directory. $! \n";

while (defined ($filename = readdir(DIR)) ) {
open (INPUT, "<c:\\Temp\\directory1\\".$filename) or die "Can't open the
file $filename\n";
until (eof(INPUT)) {
chomp($line = <INPUT>);
print "$line\n";
}
}
closedir(DIR);

and the results that I am getting is:
Can't open the directory. Permission denied.


The OS that I am using is WinXP Pro and I'm logged on as the Administrator.

Any thoughts?

Andrew.
 
J

Jürgen Exner

Andrew said:
I'm trying to learn how to use the opendir() function with perl, and each
time I try to run my perl script I keep getting "Permission denied".

Here is the script:


open (DIR, "c:\\Temp\\Directory1") or die "Can't open the directory. $!
\n";

Why are you using "open()" when you try ot learn about "opendir()"?

[...]
and the results that I am getting is:
Can't open the directory. Permission denied.

jue
 
J

John Bokma

Jürgen Exner said:
\n";

Why are you using "open()" when you try ot learn about "opendir()"?

LOL :)

Also study the File::Find module in case you want to process files
recursively in directories.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top