Many thanks to Gunnar. His suggestion to add the line about 'fatals to browser' reminded me I left off other lines necessary for cgi scripts to work properly. Below lies my revised script, which works quite well except for the one thing I want it to do...
I run an organization with members all over the northeast. Members use our website to find other members that live nearby. People sign up by filling out a web form where they enter their street address. I use a cd of mine with some mapping abilities to determine the latitude and longitude of their location. Then a cgi script I wrote calculates distances. I would like to bypass the manual determination of their coordinates. There are websites that do that after all. I thought the 'get' command would allow me to do it automatically. For the url (the argument to "get") I would add a question mark to the main address of such a website to feed it data about the locations of members, then analyze what 'get' returns in order to pick out the latitude and longitude, and finally, store those numbers in my data. Saves me work and I have my results right away. Here's my script called locate.pl: #!/usr/local/bin/perl use CGI ':standard'; use CGI::Carp "fatalsToBrowser"; print "Content-type: text/html\n\n"; use LWP::Simple; $propertime = time * 1000; $v = "http://www.hoursystem.net/advsrchexpl.htm"; $w = "http://stevemorse.org/jcal/latlon.php?cookie=&hidden=&doextra=&time=" . $propertime . "&addr2latlon=1&address=823+Alter+St.&city=Philladelphia&state=PA&zip=19147&country=US&latlon2addr=0&latitude=&longitude="; $x = "http://www.yahoo.com"; $htmlText = get($v); print "htmlText = $htmlText"; By changing a variable in that second to last line (between $v, $w and $x), the script will get one of 3 different url's. I tried it first with $v, a page from my own site. It totally worked, as it did with other ordinary sites like yahoo. But I can't get it to work with $w, the website that calculates co-ordinates. I execute the script by typing www.hoursystem.net/locate.pl into the address window of my browser. When it works (with $v and $x) I get the output I expect, and what I typed remains in the browser's address window. But when I go with $w, the text in the browser window changes to http://www.hoursystem.net/latlon.php. There's no such thing - I don't do anything with php. That's like an amalgamation of what I entered and the argument to my 'get' command. Predictably, I get an error message saying that url wasn't found on the server. Can anyone help? Thank you. By the way, in case you're wondering, that bit in the script with $propertime is because that site uses the time to calculate longitude. I tried this by just putting in an appropriate value and avoiding concatenation of the string - same results. Fred Kittelmann --- On Tue, 4/21/09, hOURS <h_o...@yahoo.com> wrote: From: hOURS <h_o...@yahoo.com> Subject: libwww-perl library To: beginners@perl.org Date: Tuesday, April 21, 2009, 6:27 PM Hi all, The get function in the libwww-perl library would be really useful to me, but I'm having problems making it work. When I use it in a cgi script (it's ultimate destination) it fails. My browser displays a generic error message which isn't very helpful. Trying to figure this out I ran a script with get from my own computer. I have two versions of Perl, 5.6 and 5.8. When I use the former, downloaded from the cd that comes with the book Perl for Dummies, 3rd edition. It works as advertised. But when I use the later version of Perl, downloaded off a website, I get the following message: Can't locate LWP/Simple.pm in @INC (@INC contains: .) at testC.pl line 1. BEGIN failed--compilation aborted at testC.pl line 1. testC.pl is the little script I wrote to try this out. Here's the code for it: use LWP::Simple; $v = "http://www.hoursystem.net/advsrchexpl.htm"; $htmlText = get($v); if($htmlText =~ m/text I am curious about/) {print "Match"} else {print "No match"} Is the library something I would have had to download separately when I upgraded to 5.8? Could the folks who host my website simply not have the library? That seems odd. It's kind of basic, isn't it? They are something of a lame outfit, but not ridiculously so. They have sendmail and let me telnet and stuff. Any clues or guesses people might have about this would be helpful. Ultimately I suppose I'll have to ask my host, but I don't really understand enough about libraries and all to even ask an intelligent question. Thanks much! Fred Kittelmann hOURS 215-551-1490 www.hoursystem.net