The problem is that Comm.pl is ancient history.
Comm::open_proc() has created a glob proccommutils000001 in the calling package, and that is the file handle. It has returned the string "proccommutils000001" which has been assigned to $Proc_pty_handle. This is what used to be known as an "indirect filehandle".
Unfortunately, with "strict refs" in effect you can not use an indirect filehandle. Current open documentation warns you about that.
You could turn off strict 'refs' wherever you want to use the $Proc_pty_handle. Or you can construct a ref to the glob whose name is in $Proc_pty_handle, and that is an OK filehandle ! The following illustrates what's going on:
and gives:use strict ; use warnings ; my $handle = oldstyle('FHOO') ; print FHOO "Open Worked !\n" ; print FHOO "Yes indeed !\n" ; { no strict 'refs' ; print $handle "Via \$handle, but no strict 'refs'\n" ; } ; my $FH ; { no strict 'refs' ; $FH = \*{$handle} ; } ; print $FH "Now via \$FH, with strict 'refs'\n" ; print $handle "Will throw error under strict 'refs'\n" ; sub oldstyle { my ($indirect_handle) = @_ ; # $indirect_handle contains nam +e of handle to open on { no strict 'refs' ; open $indirect_handle, '>&1' ; } ; return $indirect_handle ; } ;
Open Worked !
Yes indeed !
Via $handle, but no strict 'refs'
Now via $FH, with strict 'refs'
Can't use string ("FHOO") as a symbol ref while "strict refs" in use at shakerattleandhum.pl line 25.
where $handle above is equivalent to what is returned into $Proc_pty_handle.
Updated to put back the use strict ; use warnings ; that had somehow gone walkabout -- one of those slips between cup and lip we hear so much about....
In reply to Re: Comm.pl Help
by gone2015
in thread Comm.pl Help
by NateTut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |