Hi Monks,
I currently found an example of CPAN Module IO::Multiplex which doesn't work the way it's printed in the module-pod.

Here comes the code that doesn't work:

package Player; my %players = (); sub new { my $package = shift; my $self = bless { mux => shift, fh => shift } => $package; # Register the new player object as the callback specifically for # this file handle. $self->{mux}->set_callback_object($self, $self->{fh}); print $self->{fh} "Greetings, Professor. Would you like to play a +game?\n"; ...
Now here is the bug (it is really a bug?) the  print $self-{fh} "whatever"; brings up the error:
String found where operator expected at server.pl line 42, near "} "Gr +eetings, Professor. Would you like to play a game?\n"" Missing operator before "Greetings, Professor. Would you like to play + a game?\n"?) syntax error at server.pl line 42, near "} "Greetings, Professor. Woul +d you like to play a game?\n""
After changed it to:
my $fh = $self->{fh}; print $fh "Greetings .....";
all is fine.

The question is now, is this in general not possible to print to a hash-stored-handle by deref it during the print command, or am I missing something ?

Thnx

----------------------------------- --the good, the bad and the physi-- -----------------------------------

In reply to print on a hash-stored-handle by physi

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.