Hi,

Randy W. Sims wrote:
Here is a routine I wrote a while back originally for scanning plugins. I've pruned it down (It could probably be much simpler as this routine does a breadth first scan which requires more bookkeeping, but I'm too lazy to fix it...), and it appears to work with directories containing spaces. Let me know if this gets you any closer to a solution.

Thanks. Your script prints out everything in the current folder including spaces. May I how to incorporate this into checking/deleting files/folders with mtime +30?


Regards,
Norman

#!/usr/bin/perl

use strict;
use warnings;

use File::Spec;


my @dirstack;


scan_dir('.');

sub scan_dir {
  my $dir = shift;
  return unless -d $dir;

my @subdirs;

  opendir DIR, $dir or die "Can't open directory ($dir): $!\n";
  while (my $file = readdir DIR) {
    next if $file eq File::Spec->curdir()
         or $file eq File::Spec->updir();

    my $path = File::Spec->catfile($dir, $file);
    if (-d $path) {
      push @subdirs, $file;
      next;
    } else {
      print "$path\n";
    }
  }
  closedir DIR;

  foreach my $subdir (@subdirs) {
    push @dirstack, $subdir;
    scan_dir(File::Spec->catdir($dir, $subdir));
    pop  @dirstack;
  }
}


--
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