use strict; use Data::Dumper; use IO::File; ########################################################################### # Helper sub routine calls ########################################################################### system ("clear"); print "Building project config.\n\n"; sub find { my ( $dir ) = @_; my $dh; my @theseFiles; opendir $dh, $dir or return; while(my $file = readdir $dh ) { next if $file =~ /^\.{1,2}$/; my $full_file = "$dir/$file"; if ( -d $full_file ) { push(@theseFiles,find($full_file)); } else { push(@theseFiles,$full_file); } } closedir $dh; return @theseFiles; } ########################################################################### # Main routine starts here ########################################################################### ## Grab all files ## my @files = find('.'); ## Filter out CVS ## my @noCvsDirs; foreach my $file (@files) { push(@noCvsDirs,$file) unless(($file =~ /\/CVS\//) || ($file =~ /\~/)); } ## Save out to config file hwconfig.cfg ## #my $dump = Data::Dumper->new([\@noCvsDirs])->Purity(1)->Indent(0); #my $state = $dump->Dump(); my $state = join("\n",@noCvsDirs); my $fh = new IO::File(">hwconfig.cfg"); die("Checkpoint failed for hwconfig.cfg - $!\n") unless($fh); my $bytes = $fh->syswrite($state, length($state)); $fh->close(); unless($bytes == length($state)) { die("Checkpoint failed, incomplete write for hwconfig.cfg\n"); } else { print "Saved $bytes bytes into file: hwconfig.cfg\n"; } exit;