I have a handle to a socket in an hashref: $self->{socket}
.
I want to read from it using $line = <$self->{socket}>
, but I get a syntax error.
Now, I know that
print {$self->{socket}} "Hello";
Will take care of printing, but
$line = < {$self->{socket}} >;
Doesn't work.
How do I do this without cluttering up my code like this:
$fh = $self->{socket};
$line = < $fh >;
Thanks.
<fh>
is short for readline(fh)
<$fh>
is short for readline($fh)
<...>
is short for glob(qq<...>)
The shortcut is out of the question, so use the long form.
readline($self->{socket})