in reply to Re: Network Programming With Perl example 1
in thread Network Programming With Perl example 1

Originally the code was verbatim but I changed it because it didn't work. Even using your code doesn't work.

Now using

#!/usr/bin/perl #use warnings; #use strict; use IO::Socket; my $server = shift; my $fh = IO::Socket::INET->new($server) or die "Error: $!"; my $line = <$fh>; print $line;
and getting
C:\Documents and Settings\admin\Desktop\Scripts>perl network.pl mail.h +otmail.com:smtp Error: Unknown error at network.pl line 8. C:\Documents and Settings\admin\Desktop\Scripts>

Replies are listed 'Best First'.
Re^3: Network Programming With Perl example 1
by tlm (Prior) on May 01, 2005 at 02:58 UTC

    Sorry, I forgot that on Windows you should use $^E instead of $! for the error message. This won't solve your problem, but at least it may get you a more informative error message than what you got with $!.

    the lowliest monk

Re^3: Network Programming With Perl example 1
by chas (Priest) on May 01, 2005 at 03:01 UTC
    Works for me (on Windows 98 with Perl 5.6.1):
    (using your code)
    C:\perl>perl test.pl mail.hotmail.com:smtp 220 mc9-f39.hotmail.com Sending unsolicited commercial or bulk e-mail +to Microso ft's computer network is prohibited. Other restrictions are found at h +ttp://priv acy.msn.com/Anti-spam/. Violations will result in use of equipment loc +ated in Ca lifornia and other states. Sat, 30 Apr 2005 20:00:05 -0700

    chas
      Well what in the world can be going wrong? Do you think I should re-install Perl? I have 5.8x.
        No, it works fine with Activestate Perl 5.8.0 for me. You have to be connected to the web, of course ;-)
        (I tried it disconnected, and got an "Invalid Argument" error, but I didn't imagine that was the problem you are having. Did you try "perl -c" on your script?)
        chas