Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: socket help

by nagalenoj (Friar)
on Apr 23, 2010 at 12:16 UTC ( #836511=note: print w/replies, xml ) Need Help??

in reply to socket help

Sorry! Posted in curiosity. But, now I've found. It is because of
print <$fh>;
Need to do like this.
$var = <fh>; print $var;

When we do something like 'print <fh>' it reads till EOF and prints entire content. Since, I've tried in sockets, I wouldn't have received EOF. So, the above code didn't work as expected.

Replies are listed 'Best First'.
Re^2: socket help
by almut (Canon) on Apr 23, 2010 at 12:26 UTC

    FWIW, this could also be achieved by saying

    print scalar <$fh>;

    (the <> operator (aka readline) behaves differently depending on context — which by default is "list" with print)

Re^2: socket help
by sierpinski (Chaplain) on Apr 23, 2010 at 16:31 UTC
    I'm glad you figured it out. For reference in the future, it helps a lot if you can specify what your expected results are, and what your actual results are, to help diagnose the problem.

    Good job on fixing it though!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://836511]
[Eily]: I'm programming in python
[Eily]: I think I'm doing something like 3-4 google searches for each line that I write
[Eily]: I feel so efficient :D
[Eily]: (and it's not perl, where one line can do more than one thing at once...)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2018-05-22 15:05 GMT
Find Nodes?
    Voting Booth?