meanroc has asked for the wisdom of the Perl Monks concerning the following question:

Hello guys, I am new with the IO::Socket::INET, and when I run this code:

#!/usr/bin/perl use warnings; use strict; use IO::Socket::INET; my $target=<STDIN>; chomp $alvo; my $socket = IO::Socket::INET ->new( PeerAddr =>"$alvo", PeerPort =>"80", Timeout =>"10", Proto =>"tcp ); if ($socket){ print "Works!"; } else { print "fail!"; }

And i write: http://www.google.com , but returns "fail!", I want to return "works!", what I shoud done? what is wrong? Thanks guys, I liked this forum.

Replies are listed 'Best First'.
Re: IO::Socket::INET dounds
by Kenosis (Priest) on Jan 27, 2014 at 00:22 UTC

    Change my $target=<STDIN>; to my $alvo=<STDIN>;, change Proto =>"tcp to  Proto =>"tcp", and just enter www.google.com at the command line.

    Output after these changes:

    Works !