mark@cheers.jsc.nasa.gov (Mark Manning/Metrica) writes: }Recently, someone posted some stuff about connecting to a }web site via sockets. I liked the idea and the code looked }fairly simple so I downloaded it. I'm glad I did because }I'm now using a similar script in a MacPerl program which }will eventually be moved to a Unix box and IBMs. } [snip] }# }# Code from Paul Schnider on the MacPerl list. }# Actually it was code from Vlad Ionesco that I rewrote a little so that it would work under MacPerl. [snip] And if you have the original message, you'll notice that at the end I say: }And here's how I'd do it: } }#! perl } }use LWP::Simple; } }getprint "http://bb.gt.kth.se/cgi-bin/bbplupp.cgi"; } (And afterwards, I even fixed the Mac libwww-perl-5 port so that this would actually work, rather than spitting out Unix text!) That was a hint, but I'm sure the message wasn't clear. Here's the message: DON'T REINVENT THE WHEEL unless you really have to. There's a lot in your code that looks pretty questionable, but I don't have time to look at it in detail right now. But if you just want to grab some URL over the net, *use libwww-perl-5* if you at all can. (Why is that part inside a while loop, why are socket and connect called every time through the loop, why do you speak of sending when most of this code reads from the socket?) That way you don't *have* to worry about the sockets. If you're trying to do something else, and you do need to handle the sockets on your own, *please* look at IO::Socket, which inherets from IO::Handle. You should use Shuck to look both :lib:IO:Socket.pm and :lib:IO:Handle.pm. There's a lot going on under the hood in all of these modules, and they're more likely to get it right than I am. Perl 5 comes with lots of powerful OO modules to make it easier to get tasks accomplished, and you can get lots more from CPAN. You should use them unless it's really necessary not to. --- Paul J. Schinder NASA Goddard Space Flight Center Code 693, Greenbelt, MD 20771 schinder@pjstoaster.pg.md.us