in reply to what's with last;

Earlier replies (++) focus on the "right" way to address what you are trying to do.

I'll try to guess and correct the intent of the code you currently have, and provide an easy way to make the code operational. Note: I did not say "correct". This may be useful if you just need a quick, functional hack.

Your are experiencing this problem because you are using a BLOCKING socket read.

The simplest adjustment would be to get rid of the "last", and move the closing curly-brace for the "while" such that it encloses all statements except the socket close.

while(defined($buf = <$socket>)) { #Remove "last;" and closing brace ##print ..statements..etc ... } # Place Closing brace AFTER print statements $socket->close();

     "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom