learningperl01 has asked for the wisdom of the Perl Monks concerning the following question:
opendir (TXT, "$processedDirPath") or die "Cannot open + $processedDirPath directory $!\n"; while ( (my $matchingFiles = readdir(TXT)) ) { if ( $matchingFiles =~ /\.rtsd001$/ ) { my @fileContents; my $UNMODIFIED; my $MODIFIED; open(UNMODIFIED, "<$processedDirPath/$matching +Files") or die "Cannot open $UNMODIFIED for reading $!\n"; open(MODIFIED, ">$processedDirPath/$matchingFi +les.old") or die "Cannot open $MODIFIED for writing $!\n"; while (<UNMODIFIED>) { /STRUC20/ and @fileContents=(), next or pu +sh @fileContents, $_; # All files that end in rtsd001 will need to be + modified. } print MODIFIED @fileContents; close(UNMODIFIED); close(MODIFIED); system( "/bin/mv", "$processedDirPath/$matchin +gFiles.old", "$processedDirPath/$matchingFiles" ) == 0 or warn "Move +command filed $!\n";; } } closedir TXT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Readdir against large number of files
by moritz (Cardinal) on Oct 28, 2009 at 17:18 UTC | |
by learningperl01 (Beadle) on Oct 28, 2009 at 17:58 UTC | |
by almut (Canon) on Oct 28, 2009 at 19:03 UTC | |
by moritz (Cardinal) on Oct 28, 2009 at 18:45 UTC | |
|
Re: Readdir against large number of files
by JavaFan (Canon) on Oct 28, 2009 at 17:17 UTC | |
|
Re: Readdir against large number of files
by jakobi (Pilgrim) on Oct 28, 2009 at 17:26 UTC | |
by learningperl01 (Beadle) on Oct 28, 2009 at 17:53 UTC | |
|
Re: Readdir against large number of files
by gmargo (Hermit) on Oct 28, 2009 at 18:16 UTC | |
by Not_a_Number (Prior) on Oct 28, 2009 at 20:34 UTC | |
by gmargo (Hermit) on Oct 28, 2009 at 22:50 UTC |