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 warnings gives "Page Cannot Be Displayed" 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hello,

Ok I know you all say to use strict & use warnings, however the current script i'm working on started to give me "Page Cannot Be Displayed" error.

Not a perl error msg but more a browser DNS page error.

I removed from the script "use warnings" and the script runs fine.

Any idea why this could be happening and why if the "use warnings" is picking up an error - it isn't being displayed and I get a DNS error instead ?

I've also noticed that using this pragma (i think thats the right terminology?)

I had this in another script where i was getting "Page cannot be displayed", I removed the "use warnings" and I got an actual error msg, I cant remember what it was exactly something like i'd missed a curley, square or round bracket or a quote or something - you know that error that makes your script a "Runnaway" - I think thats right, I wish I new more "PERL speak" to explain it better.

anyway, all help appreciated.

 
I assume that your script is a CGI script.
When you enable warnings, you are probably getting (not surprisingly) warnings.
Since it's running on a webserver and is run on behalf of the browser, the warnings are probably then sent back to the browser. The trouble is, HTTP is fairly strict on what is and is not acceptable and therefore the webserver is probably rejecting the page because of these warnings.
I suggest that you run the script manually with the warnings and see what warnings are appearing. Then, resolve the problems so that no more warnings appear and finally, all should be well.

BTW: I doubt that this has anything at all to do with DNS.


Trojan.
 
Warnings aren't normally sent back to the browser. However I would still make sure that you print your header before any warnings get a chance to occur and see if that solves your problem.
 
Much more likely solution - what version of Perl are you running? The warnings pragma was introduced by 5.6.0, so if it's older than that (some hosts are still using 5.004 - yuck!) you'll have to change it.

If that's the case, instead of using `use warnings;', you can add -w to your shebang line, i.e.:
Code:
#!/usr/bin/perl -w
... of if you're using taint mode:
Code:
#!/usr/bin/perl -wT
 
Thanks, You have to remember I have no control over the PERL it's on a web host and don't have it local.

I'm happy to just leave the warning out as it doesn't seem to work for the moment, i'll still use the strict and put that -w on it and see what happens.

regards,

1DMF
 
1DMF - Try selecting everything from the <body> to the end of the page and delete it. Reload the page in your browser and see if you get a better 'PERL' error message. If so that may help you track down your error. Then just undo your deletion. You may need to repeat this process a few times selecting the next closest tag to the top of your page. Not seeing your code makes it harder to tell you where to start.

I hope that helps. I've used that technique a few times to get a better error message.

 
ok i've gone through my script and found the culprit.

Code:
@lterm = map $_->{Term}, @trm;

this was given to me via another thread and works fine, but obviously throws a warning, which even with me printing a header straight after the shebang still doesn't display.

-wT gives me the script failed to return the hhtp headers error msg.

I'm assuming that the code is throwing a "use of implicit blah blah has been deprecated"

and one know a fix ?

regards,
1DMF
 
The only situation I can think of where that would give you a problem would be if your @trm array has an element that isn't a hashref. If it has contains a hash that doesn't have a key called `Term', it's possible that that might cause a warning later, if you're trying to print the elements of @lterm.
 
The first element $trm[0] is null / empty is that a problem ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top