in reply to Re: check if it is a file or directory
in thread check if it is a file or directory

... but your solution does not do what the OP wants:
  • Comment on Re^2: check if it is a file or directory

Replies are listed 'Best First'.
Re^3: check if it is a file or directory
by saintex (Scribe) on Feb 27, 2010 at 07:22 UTC
    But changing dir maybe a better solution for a more compact code. For example:
    $oldFolder='C:\Documents and Settings\user\Desktop'; opendir OF, $oldFolder or die "\nCannot open dir $old1Folder: $!\n"; chdir $oldFolder; while ( my $name=readdir OF) { next if $name =~ /^\./ or -f $name; # not interesting . o .. (or hidden files) neither in plain files print $name; } closedir OF;
    now -f test in oldFolder.
      I incorporated elements of your script into this:
      #!/usr/bin/perl use strict; use warnings; use Path::Extended::Dir; my $dir = Path::Extended::Dir->new('/root/Desktop'); $dir->open; chdir($dir); while( my $entry = $dir->read($dir) ) { next if $entry =~ /^\./ or -f $entry; print $entry, "\n"; } $dir->close;
      I decided to use Path::Extended::Dir to try to get better control.