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

Writing Dir Names into a File

Thread Previous
garrett esperum
March 29, 2002 12:43
Writing Dir Names into a File
Message ID:
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 

Thanks Again!!


Chat with friends online, try MSN Messenger:

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About