Loading ...
Sorry, an error occurred while loading the content.

Opendir usage

Expand Messages
  • Giorgio Maretti
    Hello, I am an absolute beginner. I need to print a list of all files inside a directory. I tried writing something like the following, but it does not seem to
    Message 1 of 2 , Jul 10, 2002
    • 0 Attachment
      Hello,
      I am an absolute beginner. I need to print a list of all files inside a
      directory. I tried writing something like the following, but it does not
      seem to work, although it does not give error messages.


      #!/usr/bin/perl
      opendir(UTENTI,"/usr/local/cgi-bin/users/");
      $elenco = readdir UTENTI;
      foreach $riga(@elenco) {
      print "$riga\n";
      }
      closedir UTENTI;



      Saluti da Giorgio Maretti
      C.I.L.E.A. via R. Sanzio, 4 20090 Segrate MI
      tel.: +39 02 26995213; fax: +39 2 2135520
      e-mail: mailto:maretti@...
    • Richard Watts
      #!perl -w opendir(TEMP, ./ ) || die Cannot open current directory $! ; @files=readdir TEMP; closedir(TEMP); print @files; ******************** Richard Watts
      Message 2 of 2 , Jul 11, 2002
      • 0 Attachment
        #!perl -w

        opendir(TEMP, './') || die "Cannot open current directory $!";
        @files=readdir TEMP;
        closedir(TEMP);

        print @files;

        ********************
        Richard Watts
        IT Department
        Magnolia Corporate Services



        Date: Wed, 10 Jul 2002 15:40:48 +0200
        From: Giorgio Maretti <maretti@...>
        Subject: Opendir usage

        Hello,
        I am an absolute beginner. I need to print a list of all files inside a
        directory. I tried writing something like the following, but it does not
        seem to work, although it does not give error messages.


        #!/usr/bin/perl
        opendir(UTENTI,"/usr/local/cgi-bin/users/");
        $elenco = readdir UTENTI;
        foreach $riga(@elenco) {
        print "$riga\n";
        }
        closedir UTENTI;
      Your message has been successfully submitted and would be delivered to recipients shortly.