Right, FlieZilla was pushing files onto the server using an auto setting. I’ve just forced it to push it as ASCII, but got the same failed result.
I’ve also checked the encoding on ST3 and that’s set to the default ‘UTF-8’ - not something I’ve ever tinkered with.
It’s beginning to look like there’s something about the creation & transfer of the file from an external client that the server Perl program doesn’t like. Something it doesn’t get when nano is used to create a file.
I kept getting server errors. The log showed “output header” errors
So I tried changing to
#!/usr/bin/perl -w
use strict;
use HTML::Perlinfo;
use CGI qw(header);
print header;
perlinfo();
Same FAIL.
I was really scratching my head trying to figure out what was different that was causing the error.
I ended up needing to run
sudo cpan install HTML::Perlinfo::Modules
Now it works great.
Granted, I’m not the best terrible at reading error logs, but I didn’t see any type of “missing” message. This led me to believe the file had a syntax error causing the server error.
The only way I figured it out was by repeatedly Googling, trial and error, and eventually luck.
I think my next search will be to try and find a better way to deal with debugging.
Also, while cpan still works for what you need, cpanminus is regarded a superior replacement.
Also, if you want to use a different version of Perl without breaking sysperl, please use something like PerlBrew or plenv, which makes keeping track of perl versions and local libraries much easier.
As for these examples; please keep in mind that modules like CGI are deprecated in the Perl core, and that you are very much recommended to use PSGI via the use of Plack.
There are middleware packages for Plack::Handler::Apache2 if you’re required to use Apache; otherwise there are servers like Starman that you can place behind Apache2 or Nginx and just proxy through.
Have you tried downloading the file you created via nano and using a program like WinMerge to compare it to your local echo.pl file to see what differences it can find?
This is what I got with WinMerge. Same number of characters, looks like an empty line at the end of the working file (on the left), and the comment at the bottom of each pane that one came from Unix and the other from Windows.
I think we’re nearly there. I got the Windows created version of the very simple file to run by following the steps you outlined. Hurray!
Moving swiftly on, I tried it on the actual file I need to work with, but it’s still toilet time and the “End of script output before headers” message.
On a bit of whim though, I compared the encoding of the working file (UTF-8) with the failing echo.pl (UTF-8-BOM). I switched it over to UTF-8 and [FANFARE PLEASE!]
.
.