[tpm] Filehandle $fh opened only for output at ....

Tom Legrady legrady at gmail.com
Tue May 2 17:00:15 PDT 2017


I've got an old, bad program running under Perl 5.6.1 which opens a 
continuously growing file, and writes the contents to a socket, to copy 
it to another server.

It's filling the log file with lines like "Filehandle $fh opened only 
for output at filename, line 71, <$fh> line N. But $fh is opened for 
input, not output, and the contents are being copied to the remote site.


I wonder if it's because the script is trying to read after arriving to 
the current eof. The code looks like


     forever () {

         my $sent;
         while ( my $bug = <$fh> ) {
             #send buf to socket; increment $sent
         }
         # send a heartbeat to socket if not $sent
     }

Any advice? I AM working on migrating to a newer version of Perl, but 
the old version is generating a lot of junk.


Tom


More information about the toronto-pm mailing list