opendir()

Discussion in 'Perl' started by Andrew, Sep 3, 2003.

  1. Andrew

    Andrew Guest

    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.
    Andrew, Sep 3, 2003
    #1
    1. Advertising

  2. "Andrew" <> wrote in message
    news:...
    > 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ürgen Exner, Sep 3, 2003
    #2
    1. Advertising

  3. Andrew

    John Bokma Guest

    Jürgen Exner wrote:

    > "Andrew" <> wrote in message
    > news:...
    >
    >>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()"?


    LOL :)

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

    --
    Kind regards, feel free to mail: mail(at)johnbokma.com (or reply)
    virtual home: http://johnbokma.com/ ICQ: 218175426
    John web site hints: http://johnbokma.com/websitedesign/
    John Bokma, Sep 3, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob Gervais

    opendir and if -d $files problem

    Bob Gervais, Nov 7, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,636
    Steve Grazzini
    Nov 12, 2003
  2. Alex
    Replies:
    2
    Views:
    692
  3. Ramon
    Replies:
    5
    Views:
    10,776
    John C. Bollinger
    Jan 3, 2005
  4. Markus Pitha

    opendir doesn't work..

    Markus Pitha, Sep 12, 2004, in forum: C Programming
    Replies:
    5
    Views:
    465
    Markus Pitha
    Sep 12, 2004
  5. Walter Roberson

    Re: opendir

    Walter Roberson, Jul 8, 2008, in forum: C Programming
    Replies:
    0
    Views:
    417
    Walter Roberson
    Jul 8, 2008
Loading...

Share This Page