sub fetch{
my $url = '..'; # a long url with length of 800
my $cont = LWP::Simple::get($url);
die $cont; #return $cont;
}
My cgi calls the routine fetch. But nothing shows in the error_log; When using LWP::Simple::getprint($url), 200 is shown in the error_log; and content outputs to browser. Don't know why LWP::Simple::get($url) doesn't work. BTW, the server access_log tells a 200 status returned, and right content has been sent back.
I tried to run 'perl **.cgi' at command line, it doesn't return the right content.
Any help will be highly appreciated.
#######################
# fetch.pm
########################
sub ParseXML
{
my $params = shift;
my ($uid, $pwd) = Access();
my $url = 'http://www.blah.com/junk.cgi';
$url = ConstructURL($url, $params);
my $xml = LWP::Simple:get($url);
return $xml;
}sub ConstructURL
{
my ($url, $params) = @_;
my @tmp = ();
while ( my ($k, $v) = each (%$params) ){
push(@tmp, "$k=$v");push(@tmp, "$k=$v");
}
return $url . "?" . join('&', @tmp);
}##############################################
# blah.cgi
###########################################
use fetch;
use CGI ':standard';my $params = { 'a' => 1, 'b' => 9, .., 'filename' => 'xx'};
my $xml = fetch($params);
print header, start_html('Test'), p($xml), end_html;
___END___##########################################
# junk.cgi (on server B)
########################################use CGI ':standard';
my $par = param('filename');
my $fn = "$ENV{WEB_ROOT}/xml/$par.xml";
my $xml = '';
open(FH, "<$fn") ¦¦ dienice();
$xml .= $_ while(<FH>);
close(FH);
print header, $xml;__END__