#!/usr/bin/perl use strict; use warnings; use Net::Telnet; my $t = Net::Telnet->new( Timeout => 10, Port => 80 ); $t->open('www.google.com'); $t->print('GET /'); my $line = 0; while (my $o = $t->getline()) { print ++$line . '. ' .$o; } #### #!/usr/bin/perl use strict; use warnings; use Net::Telnet; my $t = Net::Telnet->new( Timeout => 10, Port => 6666 ); $t->open('mydataserver') or die "Can't connect to mydataserver: $!"; open my $fh, '>', '/tmp/file' or die "Can't write to /tmp/file: $!"; $fh->autoflush(1); while (my $o = $t->getline()) { print $fh $o; # or $fh->print($o); } close $fh;