http://www.perlmonks.org?node_id=357183

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I have a bit of a problem with this script. It seems to be working happily, searching through all subfolders for a file ending .9. But when it prints to the output file, it appends all the other subfolders containing .9 contents to the file. So naturally the file is huge? Any suggestions?
find (\&process, $folder); sub process { if ($_ =~ /\.9$/) { print "\nProcessing the fort.9 files, from taylor type to z values\ +n"; open (FILE, '<', $_) or die "Cannot open file: $!"; $/= "# input for"; while (<FILE>) { #do something push(@outLines, $_ ); } close FILE; open ( OUTFILE, ">adjusted.learn" ) or die "Cannot open file: $!"; print ( OUTFILE @outLines ); close ( OUTFILE ); } } exit;