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

Re: [PBML] Listing only sub-directories using readdir

Expand Messages
  • Don Smith
    Thanks! Don ... From: leonpeeters To: Sent: Sunday, June 01, 2003 12:14 AM Subject: Re: [PBML]
    Message 1 of 2 , Jun 1, 2003
    • 0 Attachment
      Thanks!

      Don
      ----- Original Message -----
      From: "leonpeeters" <leonpeeters@...>
      To: <perl-beginner@yahoogroups.com>
      Sent: Sunday, June 01, 2003 12:14 AM
      Subject: Re: [PBML] Listing only sub-directories using readdir


      > The test ( -d $name) will return true if the variable $name contains a
      > directory name.
      > Note that $name will need to contain the pathname component:
      > $name = "$path/$subDir1";
      >
      >
      >
      > ----- Original Message -----
      > From: "Don Smith" <dmsmith@...>
      > To: <perl-beginner@yahoogroups.com>
      > Sent: Saturday, May 31, 2003 9:23 PM
      > Subject: [PBML] Listing only sub-directories using readdir
      >
      >
      > >
      > > Folks,
      > >
      > > I'm trying to get a list of just the sub-directories in a directory. I've
      > got the following working, but it lists all the contents, not just the
      > sub-directories.
      > >
      > > I figure there has to be an easy way to do it, but after 4 hours of
      > trying, I can't seem to find it.
      > >
      > > Thanks for any help you can provide.
      > >
      > > Cheers,
      > >
      > > Don
      > >
      > > #########################################
      > >
      > > #!/usr/bin/perl
      > >
      > > use strict;
      > >
      > >
      > > print "Content-type: text/html\n\n";
      > >
      > >
      > > my $path="C:/Temp";
      > > my $dir0="$path";
      > > opendir(DIR0, $dir0) || die("Cannot open directory");
      > > my @contents0 = readdir(DIR0);
      > > closedir(DIR0);
      > > print "<table border=1>\n";
      > > my ($subDir1);
      > > foreach $subDir1 (sort @contents0) {
      > > unless ( ($subDir1 eq ".") || ($subDir1 eq ".."))
      > > {
      > > print "<tr><td><b>$subDir1</b></td></tr>";
      > > }
      > > }
      > > print "</table>\n";
      > >
      > > #########################################
      > >
      > >
      > > [Non-text portions of this message have been removed]
      > >
      > >
      > >
      > > Unsubscribing info is here:
      > http://help.yahoo.com/help/us/groups/groups-32.html
      > >
      > > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      > >
      > >
      >
      >
      >
      >
      > Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html
      >
      > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.