Help for this page

Select Code to Download


  1. or download this
    #keep based on pattern match
    opendir(DIR, $destinationDirectory) or die $!;
    ...
      next if -d $file;#skip directory entries
      unlink unless $file =~ /$pattern/;
    }
    
  2. or download this
    #keep based on a prepopulated hash
    %prepopulatedHash =(FILE1 => 1, FILE2 => 1, FILEN => 1);
    ...
      next if -d $file;#skip directory entries
      unlink unless exists($prepopulatedKeepHash{$file};
    }