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

[PBML] Re: directory listing

Expand Messages
  • Jeff Boes
    ... Easy-- opendir(DIR, $dirname) or die Can t open $dirname: $! ; while (defined($file = readdir(DIR))) { push @filelist, $file; } closedir(DIR); Taken
    Message 1 of 4 , Nov 6, 1999
    • 0 Attachment
      > -----Original Message-----
      > From: Frank Hale [mailto:frankhale@...]
      > Sent: Saturday, November 06, 1999 8:36 PM
      > To: perl-beginner@egroups.com
      > Subject: [PBML] directory listing
      >
      >
      > How can I get a directory listing in Perl and then put
      > the file names in an array?
      >

      Easy--

      opendir(DIR, $dirname) or die "Can't open $dirname: $!";
      while (defined($file = readdir(DIR))) {
      push @filelist, $file;
      }
      closedir(DIR);

      Taken directly from 9.5 of The Perl Cookbook (a highly, highly recommended
      resource for budding Perl mongers).

      ----
      "Debugging had to be discovered. I can remember the exact instant when I
      realized that a large part of my life from then on was going to be spent
      finding mistakes in my own programs." --Maurice Wilkes, creator of the EDSAC
      ___________
      Jeff Boes <>< jboes@...
      Mur Consulting http://www.qtm.net/~jboes/
    • Frank Hale
      ... God I feel stupid I have this book. Thanks for the solution. __________________________________________________ Do You Yahoo!? Bid and sell for free at
      Message 2 of 4 , Nov 6, 1999
      • 0 Attachment
        >
        > Taken directly from 9.5 of The Perl Cookbook (a
        > highly, highly recommended
        > resource for budding Perl mongers).
        >

        God I feel stupid I have this book.

        Thanks for the solution.
        __________________________________________________
        Do You Yahoo!?
        Bid and sell for free at http://auctions.yahoo.com
      • Shibu TN
        What do I do if I need the file size of all the files also? -Shibu ... recommended ... when I ... spent ... the EDSAC
        Message 3 of 4 , Sep 13, 2001
        • 0 Attachment
          What do I do if I need the file size of all the files also?

          -Shibu


          --- In perl-beginner@y..., "Jeff Boes" <jboes@q...> wrote:
          >
          >
          > > -----Original Message-----
          > > From: Frank Hale [mailto:frankhale@y...]
          > > Sent: Saturday, November 06, 1999 8:36 PM
          > > To: perl-beginner@egroups.com
          > > Subject: [PBML] directory listing
          > >
          > >
          > > How can I get a directory listing in Perl and then put
          > > the file names in an array?
          > >
          >
          > Easy--
          >
          > opendir(DIR, $dirname) or die "Can't open $dirname: $!";
          > while (defined($file = readdir(DIR))) {
          > push @filelist, $file;
          > }
          > closedir(DIR);
          >
          > Taken directly from 9.5 of The Perl Cookbook (a highly, highly
          recommended
          > resource for budding Perl mongers).
          >
          > ----
          > "Debugging had to be discovered. I can remember the exact instant
          when I
          > realized that a large part of my life from then on was going to be
          spent
          > finding mistakes in my own programs." --Maurice Wilkes, creator of
          the EDSAC
          > ___________
          > Jeff Boes <>< jboes@q...
          > Mur Consulting http://www.qtm.net/~jboes/
        Your message has been successfully submitted and would be delivered to recipients shortly.