in reply to Reading froma dynamic file handle

I always loop through a socket connection to get the data that I want. my code would be as follows:

Code is untested

#!/user/bin/perl -w use strict; use IO::Socket::INET; sub sock_connection{ my $sockname = new IO::Socket::INET(PeerAddr => "putAddrHere", PeerPort => "Port", Proto => "tcp") or die "cannot +connect to host: $!"; print $sockname "@_" # Puts data passed to sub shutdown($sockname, 1); while(<$sockname>){ # place regex to remove prompt message # Display msgs using print $_; } undef $sockname }

if the code is called in a subroutine, like the above, you can then call the subroutine to loop through the code that you want to send to the socket.

sock_connection("my command here")

Hope this helps?!

Edit:Added the undef to clear the socket connection when done.