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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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


New User

Dec 9, 2010, 8:13 PM

Post #1 of 2 (1087 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.

#!/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 = "";
my $page = get($url);
print $page;
print "</html>\n";

Veteran / Moderator

Dec 10, 2010, 5:53 AM

Post #2 of 2 (1076 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.

use strict; 
use warnings;

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

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