I'm currently trying to write some CGI scripts for a website that i'm developing for work. I'm a little new at this, so everything is a 'suck it and see' approach.

Anyway, I've gotten so far, but am stuck on the following. Its a (rather simple) CGI script called from a html form.

#!/usr/bin/perl use CGI; my $query= new CGI; my $pdb_file = $query->param('pdbcode'); print $query->header(-type => 'text/html'); print $query->start_html(-title => "Secondary Structure Analysis"); MainProgram($pdb_file); $query->end_html( ); ####################################################### # 'main' subroutine sub MainProgram { my($pdb_file) = @_; my $dssp = ".dssp"; my $dsspdir = "http:/mywebsite/datafiles/"; my $pdbcode = substr($pdb_file, 0, 4); my $dssp_file = "$dsspdir$pdbcode$dssp"; print $query->('dssp file used is $dssp_file'); }
When I submit data to the preceding form, this script returns a blank page. And when I try running the script from the command line I get the following error

Not a CODE reference at ./script.cgi line 45.

Could anyone please suggest as to what might be going on? Any help much appreciated.


In reply to CGI script query by Angharad

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.