Hi list, I've got some strange behaviour with redirected STDOUT/STDERR handles and calls to File::Copy - I hope someone can explain me why I'm seeing what I'm seeing here.
I use the following code to redirect STDOUT and STDERR to a log file - as you can see, it's more or less copied directly from the Perl Cookbook: my $log_file = 'log.txt'; my $file1 = $ENV{'HOME'} . '/.bashrc'; my $file2 = $ENV{'HOME'} . '/.bashrc.bak'; # copy STDxxx open (OLDOUT, ">&STDOUT") or die "could not duplicate STDOUT : $!"; open (OLDERR, ">&STDERR") or die "could not duplicate STDERR : $!"; # redirect STDxxx to the log file open (STDOUT, '>', $log_file) or die "could not redirect STDOUT to $log_file : $!"; open (STDERR, ">&STDOUT") or die "could not redirect STDERR to STDOUT : $!"; copy ($file1, $file2) or die "could not copy : $!"; close (STDOUT) or die "could not close STDOUT : $!"; close (STDERR) or die "could not close STDERR : $!"; # re-open STDxxx to the normal handles open (STDOUT, ">&OLDOUT") or die "could not reopen STDOUT : $!"; open (STDERR, ">&OLDERR") or die "could not reopen STDERR : $!"; # close the temporary handles just to be sure close (OLDOUT) or die "could not close OLDOUT : $!"; close (OLDERR) or die "could not close OLDERR : $!"; This code of redirecting STDOUT/STDERR does work normally, I'm using it (as a method) in several places with different commands in the middle (mostly system() calls), the output gets directed to a log file, and after the execution everything printed on STDOUT can be seen on the console window again. The problem occurs when I call "copy()" after redirecting the output - I do not get an error, but each call to copy results in the warning message Filehandle STDERR reopened as FH only for input at /usr/lib/perl5/5.8.3/File/Copy.pm line 118. In Copy.pm at line 118 I find open($from_h, "< $from\0") or goto fail_open1; I've googled for this message, but I did not find anything that would explain this behaviour - the call to copy works, the output is redirected as expected, and afterwards the output handles are restored successfully. Why do I get this message? What does it mean, and is there a way to avoid it? Thank you very much in advance for any explanations :-) Philipp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>