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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.