develooper Front page | perl.beginners | Postings from March 2002

Writing Dir Names into a File

Thread Previous
From:
garrett esperum
Date:
March 29, 2002 12:43
Subject:
Writing Dir Names into a File
Message ID:
F103QfP9NFlWJI2mtmS0000da9b@hotmail.com
Hello all,

Sorry about my previous message, I left alot of key info out. I am using 
Solaris 2.6. I want to read all of the directory names after $mydir, and 
then print those names into a file. How do I do this?

Currently I have this as my script:

#!/path/to/perl -w
use strict;
   my $dir = '/images';
   opendir( DIR, $dir )
      or die "Failed to open directory '/images': Error='$!'";
while ( my $file = readdir( DIR ) ) {
    print $file," is a directory!\n" if -d "$dir/$file";
}

I want to see other examples of how you do this. I haven't found much on the 
web.

Thanks Again!!

-garrett

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About