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:

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 ; } ;
and gives:
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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.