Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Use of uninitialized value"

Status
Not open for further replies.

sarahknz

Programmer
Mar 22, 2004
26
NZ
My webhost has cPanel which only accepts Perl scripts, aargh

So I'm using this to get Perl to call my real PHP scripts which do all the work


Code:
#!/usr/local/bin/perl -w
use LWP::Simple;
use CGI;
my $URL="my $content = LWP::Simple::get($URL);
print "$content";

I have 2 cron jobs, 2 Perl scripts and 2 PHP scripts.

Both the PHP scripts are called using the full URL even though one is on the same server. Both PHP scripts will work if called directly.

Now, one of the Perl scripts works, but the other doesn't. I get


Quote:
Use of uninitialized value in string at /home/bots04/public_html/myscript.pl line 10.


sent to me by the cron job. If I call it in the browser I get a 500 error. Line 10 is the print "$content"; statement.

Any ideas why it might decide to fall over?

Sarah



 
LWP::Simple::get is returning undef because it is failing. Therefore, $content is not initialized. Which PHP script is this, the one on the same server?

 
because you've already 'used' LWP::Simple at the beginning of the script, you don't need to call it again, i.e. line 9 simply needs to be:
Code:
my $content = get($URL);
I think if you are going to remotely call a module the code is actually something like:
Code:
my $content = LWP::Simple->get($url);
But don't quote me on that, likewise if you are just printing a variable, such as you are in line 10, you don't need to enclose it in these ". For axample:
Code:
print $content;
or
Code:
print "Content=\n".$content."\n";
also make sure you use 'warnings' and 'strict' these somethimes help debug buggy scripts.

Rob Waite
 
Thanks for the replies.

The script is failing for the PHP script on the same server.
The original script, which calls a different server, works fine.

Both have 755 for permissions, both output to $content

I've upped the permissions to 777

I tried running the perl script on another server which I could also vi the script and there are no stray characters. It's very clean. On that server I got a 403 error, not a 500 error and I'm not sure quite what the problem was...

I've also tried the suggestions noted above, with no improvement...

Sarah

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top