CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Using the "get" function via a web page

 



sklassen
New User

Dec 9, 2010, 8:13 PM

Post #1 of 2 (960 views)
Using the "get" function via a web page Can't Post

Okay.. I'm trying to write a script to access via the web that will display a web page fetched by the "get" function. This only works at locally at the command line and not on the web. Can anyone tell me why this isn't working if I access it via the web? There's got to be a simple answer. Thanks for the help in advance.


Code
#!/usr/bin/perl -w 


use XML::RSS;
use LWP::Simple;
use HTML::Entities;


print "Content-type:text/html\r\n\r\n";
print "<html>\n";

my $url = "http://www.google.com";
my $page = get($url);
print $page;
print "</html>\n";



FishMonger
Veteran / Moderator

Dec 10, 2010, 5:53 AM

Post #2 of 2 (949 views)
Re: [sklassen] Using the "get" function via a web page [In reply to] Can't Post

Telling us that it doesn't work without including any info on what happens is meaningless to us.

Start by removing the -w switch and add the strict and warnings pragmas, which should be in every script you write.

Code
use strict; 
use warnings;


When debugging cgi script, use the CGI::Carp module.

Code
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);


Remove the printing of your html tags, the fetched page should already include those tags.

Unless you need to do something with the fetched html, use the getprint() function instead of the get() function.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives