Hello,

I'm trying to write a script that will recurse through a directory structure 
and write all files not specified in a "control" file into a second file.  
So, to break it down.  I would give you file with a list of filepaths each 
one on a new line (i.e. /docroot/bvdev1/index.html).  I would then run the 
script starting in a certain directory (i.e. /docroot/bvdev1/).  It would 
then write out all files not listed in the first file to a second file.  
Because /docroot/bvdev1/index.html was in the first file, it would not be 
written into the second file.  /docroot/bvdev1/webmaster.html would be 
written to the second file.

I have attempted at this script and have gotten stuck when trying to do the 
matching.  What I have so far is below.

I would appreciate any help that anyone can offer.

Kevin
[EMAIL PROTECTED]



#!/usr/bin/perl
# Script that recurses through a directory structure and write all files not 
specified in a "control"
# file into a second file.

use Cwd;


# Get file to be processed
$process = $ARGV[0];
#print "File to be processed: " . $process . "\n";


# Establish what directory we are in
if ($ARGV[1] == null) {
        $base_dir = cwd;
} else {
        $base_dir = $ARGV[1];
}

#print "Base Dir: " . $base_dir . "\n";

# Open Control File
open(FILE, $process);
# Read Control File
@control_list = <FILE>;

&get_files;




foreach $item (@control_list) {
        chop($item);
        foreach $file (@files) {
                chop($file);
                if($file == $item) {
                        print "$item";
                }
        }


}




sub get_files {
        undef(@files);
        opendir(DIR,"$base_dir") || die ("Cannot open $base_dir for read");
        @files = grep { $_ ne '.' and $_ ne '..' } readdir(DIR);
        #print "@files\n";
}
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to