I thank those who have answered my request--let me see if I can summarize
the recommendations:
David Wagner recommended that I reform the call using "cp":
.....
"use File::Copy cp;
$n=FileHandle->new("/dev/null","r");
cp($n,"x");'
which is not what you are trying. You are trying to use an already open
file and that I don't believe is the context of what I see in the doc. The
group can correct me ( and they will) if I am wrong."
.......
To which Rod Dixon replied that this suggestion would only read from a
dev/null.
Rod also added that I can't use the move command referencing a File Handle
because (1) the File Handle's contents were still buffered and (2) this
command can't succeed because I won't be able to delete a still open file
handle using a move.
(By the way, at this point in the program I hadn't written the file handle
to a file with a close, else I wouldn't have tried this approach at all).
Joseph Newton affirmed Dixon's point and essentially said that I was crazy
to want to copy or move a file handle even if I could.
What I thought I could do based on the documentation of File::Copy
was copy OR move a file handle regardless of the "mode" used to open it
originally or whether it'd been flushed---I had my reasons, including the
intention to write the results of the program's standard error and some
other history to a log file locally and to concatenate that local logfile
into a separate consolidated log file. I thought using File::Copy would
allow me to forego all the connection overhead associated with FTP --since
all remote servers and the destination server are Win-based, plus allow me
to send multiple files a la move without having to remove the files
successfully copied.
Whether this approach is good design or not, I'll reconsider based
on the feedback, but there was a method to my madness. As I said
originally, wheh I read this snippet from the File::Copy documentation, it
appeared to me that it is possible to copy/move a FH--no one has told me
exactly why file:copy with a FH isn't possible if it works as intended- :
--File Copy doc snippet begins here---->
" copy("file1","file2");
copy("Copy.pm",\*STDOUT);'
move("/dev1/fileA","/dev2/fileB");
use POSIX;
use File::Copy cp;
$n = FileHandle->new("/a/file","r");
cp($n,"x");'
DESCRIPTION
The File::Copy module provides two basic functions, "copy" and "move",
which are useful for getting the contents of a file from one place to
another.
* The "copy" function takes two parameters: a file to copy from and a
file to copy to. Either argument may be a string, a FileHandle
reference or a FileHandle glob. Obviously, if the first argument is
a filehandle of some sort, it will be read from, and if it is a file
*name* it will be opened for reading. Likewise, the second argument
will be written to (and created if need be). Trying to copy a file
on top of itself is a fatal error.
.... end of quoted documentation....
So I thought that using a FileHandle was permissible as a move, copy or cp
command. I wasn't trying to write to another File Handle so it looked
"acceptable".
I will forego this approach and close my log file, and use Net::FTP or
File::Copy against the files created.
Thanks all.
Jeff Smith
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]