Seventh has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help stripping characters in an array please.
by ikegami (Patriarch) on Dec 08, 2004 at 05:02 UTC | |
|
Re: Need help stripping characters in an array please.
by sgifford (Prior) on Dec 08, 2004 at 05:17 UTC | |
|
Re: Need help stripping characters in an array please.
by larryp (Deacon) on Dec 08, 2004 at 05:03 UTC | |
|
Re: Need help stripping characters in an array please.
by trammell (Priest) on Dec 08, 2004 at 04:59 UTC |