Garrett Esperum wrote: > > 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"; > }
#!/usr/local/bin/perl -w use strict; my $dir = '/directory_name'; opendir( DIR, $dir ) or die "Failed to open directory '/images': Error='$!'"; while ( defined( my $file = readdir DIR ) ) { next if $file =~ /^\.\.?$/; 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"; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]