In the past I've done a lot of (successful) command-line Perl debugging using syntax such as
perl -d:ptkdb foo.cgi "PARAM1=val1&PARAM2=val2"
where PARAM1 and PARAM2 are fields in the CGI form which invokes foo.cgi when the user presses the Submit button.
Now I would like to do the same thing, but two of the arguments are uploaded files, i.e. there's an HTML form which looks like:
<FORM ENCTYPE="multipart/form-data" ACTION="./foo.cgi" METHOD="POST">
Protease: <SELECT NAME="PARAM1">
<OPTION SELECTED>trypsin</OPTION>
<OPTION>pepsin</OPTION>
<OPTION>none</OPTION>
</SELECT><br>
Sort output by: <SELECT NAME="PARAM2">
<OPTION VALUE="mw" SELECTED>Molecular weight</OPTION>
<OPTION VALUE="pos">Position</OPTION>
</SELECT><br>
<p> Please select an OBSERVED spectrum file to upload: <BR> <INPUT TYP
+E="FILE" NAME="MEASURED_SPECTRUM"> <p>
<p> Please select a protein sequence file to upload: <BR> <INPUT TYPE=
+"FILE" NAME="SEQUENCE"> <p>
<INPUT TYPE="submit"> </FORM>
and on the CGI side we have code such as:
my $q = new CGI;
$fh1 = $q->param('MEASURED_SPECTRUM'); # these are really file-handles
$fh2 = $q->param('SEQUENCE');
...
while (<$fh1>) {
...
}
...
while (<$fh2>) {
...
}
Question: how can I invoke Perl from the command-line so that these file-handles are properly initialized?
Bonus question: In the (non-debug) CGI environment, is there any way to learn the name of the file which was uploaded? In the case of this program, the filename carries some semantic value.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.