Hello again,
So I have modified my script a bit and it works. However, now I want to not
read in the "." and ".." directories. How can I do this?? I am having
problems with this part.
I think my "while ( my $file = (!/^\.\.?$/,readdir( DIR )) )" part is wrong.
Any suggestions??
Below is my new script:
#!/usr/local/bin/perl -w
use strict;
my $dir = '/directory_name';
opendir( DIR, $dir )
or die "Failed to open directory '/images': Error='$!'";
while ( my $file = (!/^\.\.?$/,readdir( DIR )) ) {
open(OUT, ">>dir.txt") || die "Inside Func - Cant open dir.txt: $!\n";
print OUT "$file \n";
close(OUT);
# print "$file \n" if -d "$dir/$file";
}
Thanks!!!
-garrett
>From: "garrett esperum" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Writing Dir Names into a File
>Date: Fri, 29 Mar 2002 12:42:59 -0800
>
>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
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]