Hi Jeff,

DONT!

Smith Jeff D wrote:

>         I am trying to copy/move files under WinNT from remote server(s) to
> a central server using File::Copy --see code snippet below:
>
> snippet begins------
> use File::Copy;
> ......
>
> open (LOGFILE, ">>testlog") or die (print "$! problem opening testlog\n");
> print LOGFILE "$date: \n";
> print LOGFILE "This is a test of moving a handle--ONCE AGAIN\n";
> print LOGFILE "the end\n";
>
> #my $result = copy ($fromdir, $todir) or die ("Error--can't copy LogFile :
> $!\n");
> my $result = move (\*LOGFILE, $todir) or die ("Error--can't move the
> LogFile: $!\n");

Really, just don't try to mix file access and file handling.  These processes should 
be completely insulated from each other.  In fact, the system should disallow access 
for file-handling to any file currently opened.  For one thing, you have no way of 
even knowing your test statements are contained in the logfile.  Filehandles generally 
don't promise to flush until they are closed, or they receive some explicit fluxh 
command.

> close (LOGFILE);  #should come BEFORE any file-handling procedures
>
> .
>         It works fine when I pass it a literal reference for the source and
> destination using copy or move commands.  However, I can't get a reference
> to a file handle to work.  There must be something really simple that I'm
> missing.  I know that it's not a permissions issue and I know the file does
> get created once I've closed the File Handle.  I'd like to keep the file
> handle open though so that I can grab the contents of the File Handle for
> another routine.  the move command always returns 0 when referencing the
> LOGFILE file handle.   I'd like to use move so I don't have to copy the
> files and remove them from the source directory afterwards.
>
> Thanks
>
> Jeff Smith

Whatever the reason, this is the wrong way to go about it.  Even if you could make 
this work, it would be the equivalent of taking a plane aloft for a midair refeulking, 
when you could roll it over to the pump. Don't shoot yourself in the foot with fancy 
tricks.  Do file-handling only on closed files.

If your planned design requires you to keep a file handle open through a move, 
re-examine your design premises--one of them is wrong.

Joseph




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to