I'm trying trying to process all .dat files in a nested directory tree. I've used the File::Find module but it's not working how I expected it to work. I can't even concatenate the directory and the filename to open the files. I always get the error message "readline() on closed filehandle"
Any help would be deeply appreciated!
Here is the code:
use strict; use warnings; use Cwd; my $startdirectory = cwd; print "Starting directory: $startdirectory\n"; use File::Find; find ( \&inFiles, ('.') ); exit; sub inFiles { chomp; my $name = $_; my $directory = cwd; if( $name =~ /.dat/) { print "dir = $directory\tname = $name\n"; open INFILE,'<$name' || warn ("Cannot open input file $name\n"); my @infilecontent = <INFILE>; print @infilecontent; my $localfile = "$directory\$name"; #win32 open INFILE2,'<$localfile' || warn ("Cannot open input file $localf +ile\n"); @infilecontent = <INFILE2>; print @infilecontent; } } #inFiles
In reply to How to open files found via File::Find by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |