This is not doing what you think. The backslash has a special meaning in double quotes. Fortunately, you can use a normal slash /.my $dir_path="\Incoming\Temp";
Where is $tmp_dir coming from? Do you mean $dir_path? Moreover, you cannot use a non-alphanumeric character in a dirhandle name. Remove the backslash. Even better - use a lexical dirhandle:opendir (Incoming\Temp, $tmp_dir) or die $!;
opendir my $DIR, $dir_path or die $!;
Not really an error, but can be improved: use a lexical filehandle, 3-argument version of open, and test for failure:open (MYFILE, '>>vehicles.txt');
open my $OUT, '>>', 'vehicles.txt' or die $!;
BTW, have you noticed the directory path must be prefixed to the filename?while (my $filename = readdir $DIR) { open my $FILE, '<', "$dir_path/$filename" or die $!; while (my $content = <$FILE>) { print $OUT $content; } }
Perl is case sensitive. The function is in lowercase: closedir. Also, give it an argument.CLOSEDIR;
In reply to Re^3: Copy rows of file to new document
by choroba
in thread Copy rows of file to new document
by phineas629
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |