So, I don't use CGI a lot much these days. But I recently wrote a little joke module and decided to make a little HTML form interface for it. Plack would be a sensible way of doing the interface, but this was just a silly little thing and I was feeling lazy, so I coded it up using CGI instead. I'd used Moo rather than Moose so speed shouldn't have been an issue.
I uploaded it to the server and visited the page and it just showed me my Perl source code. Hmmm…
Create .htacccess and add the following lines:
Options +ExecCGI AddHandler cgi-script .cgi .pl
Visit the page again… still showing the source code. Hmmm…
Scratch head for five minutes. Open up httpd.conf, add:
<Directory /path/to/my/vhost/> AllowOverride all </Directory>
Visit the page again… still showing the source code. Hmmm…
SSH into the server and run ./myscript.cgi from the command line.
"uniq" is not exported by the List::Util module
Okay, I must have an old version of it. Upgrade.
Visit the page again… still showing the source code. Hmmm…
Stop using List::Util entirely.
sub uniq { my %seen; grep !$seen{$_}++, @_; }
Visit the page again… still showing the source code. Hmmm…
Scratch head for ten minutes. Rename to ./myscript.pl.
Visit the page again… still showing the source code. Hmmm…
Create the following file and mark it as executable:
#!/bin/sh echo "Content-Type: text/plain"; echo ""; echo "Hello world";
Visit my new page… also showing the source code. Hmmm…
Scratch head some more.
Consider buying anti-headlice shampoo.
Finally… FINALLY… after about TWO HOURS I figure out the problem! It was…
In reply to How easy it is to make mistakes by tobyink
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |