Steve Gross wrote:
> 
> I'm trying to perform an operation on every file in a directory.  I want to
> skip directories.  I'm using the "-d" file test but it only catches "." and
> "..".  Any ideas?

You have encountered an error that a lot of people make and is described
in "perldoc -f readdir".


> Here's the code (most of it out of the Cookbook):
> my $dirname = "D:\\XYZ";
> 
> opendir(DIR, $dirname) or die "can't opendir $dirname: $!";
> 
> while (defined(my $file = readdir(DIR)))
> {
>     if (-d $file)

      if (-d "$dirname/$file")


>     {
>         print "DIR: $file\n";
>         next;
>     }
>     else
>     {
>         # do something here
>     }
> }


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to