in reply to How to open files found via File::Find
and you should have better luck. You also need 2 backslashes in a double quoted string. Or use $directory . '\' . $name.open INFILE2,'<', $localfile ...
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,'<', "$directory/$name" || warn ("Cannot open input fil +e $name\n"); my @infilecontent = <INFILE>; print length @infilecontent; my $localfile = "$directory\\$name"; #win32 open INFILE2,'<', $localfile || warn ("Cannot open input file $loca +lfile\n"); @infilecontent = <INFILE2>; print @infilecontent; } } #inFiles
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to open files found via File::Find
by roboticus (Chancellor) on Jan 08, 2010 at 14:07 UTC | |
by gam3 (Curate) on Jan 08, 2010 at 19:15 UTC |