in reply to use telnet to connect to tcp session and receive data

How about IO::All?
my $io = io("$host:$port"); while ($_ = $io->getline) { next unless /some_regex/; # do stuff with line }