this is really an http server config issue not really a coding issue.

Note that the following information very much "depends" (and this isn't the forum for discussing http server issues so I will be brief as well as incomplete...read your http server docs).

if the Perl file is in a directory defined as a cgi|shellcgi directory then it will be executed (this can "depend"). if you move this file to a non-cgi directory, then it also "depends" as to what will happen, often based on the extension. I find that on windows both NS and IE will ask you to either download the script or execute it using the windows mappings...i.e. if you have Perl installed on the local box, you may be prompted as to whether you desire the script to be run using Perl.exe. On unix, I find netscape will also want to "save as" the file locally.

if you truly want your scripts to be viewed as source by everyone regardless of their platform then perhaps as easy solution is to change/remove the extension, to be sure you could copy the scripts to a non-cgi directory and rename them to script.html or just script. if on unix, be sure these are not marked executable. This is a kluge, but will work.

as far as how the scripts get viewed as code here on perlmonks....the use of a custom tag pair, as documented Site How To


In reply to Re: Script in browser by wardk
in thread Script in browser by Raincloud

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.