Dear Monks,

According to the CGI.pm docs here: CGI.pm you should be able to execute a CGI script from the command line like this:

your_script.pl name1=value1&name2=value2

However, with the following pragmas:

use CGI qw{:standard -debug};

using the above format for the form variables does not work: my perl script hangs after showing the output for the first name/value pair. Here is the output:

~/perl_programs$ ./my_prog.pl name1=value1&name2=value2 [1] 462 ~/perl_programs$ Content-Type: text/html; charset=ISO-8859-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> <ul> <li><strong>name1</strong></li> <ul> <li>value1</li> </ul> </ul> </body> </html>(HANGS RIGHT HERE!!)

If I add the pragma:

use CGI qw{:standard -debug -oldstyle_urls};

as explained here: pragmas, the same thing happens.

I am able to get this format to work:

./my_prog.pl name1=value1 name2=value2

i.e. using a space instead of an & as the separator between name/value pairs:

~/perl_programs$ ./my_prog.pl name1=value1 name2=value2 Content-Type: text/html; charset=ISO-8859-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> <ul> <li><strong>name1</strong></li> <ul> <li>value1</li> </ul> <li><strong>name2</strong></li> <ul> <li>value2</li> </ul> </ul> </body> </html>~/perl_programs$

I also can't get the semi-colon separator to work correctly using the -newstyle_urls pragma:

~/perl_programs$ ./my_prog.pl name1=value1;name2=value2 Content-Type: text/html; charset=ISO-8859-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> <ul> <li><strong>name1</strong></li> <ul> <li>value1</li> </ul> </ul> </body> </html>~/perl_programs$
Here is the test program I'm using:
#!/usr/bin/env perl use strict; use warnings; use 5.014; use CGI qw{:standard -debug -newstyle_urls}; #Cycling through various + pragmas my $q = CGI->new; print $q->header, $q->start_html; print Dump; print $q->end_html;

Other info:

$ perl -v This is perl 5, version 16, subversion 0 (v5.16.0) built for darwin-2l +evel Copyright 1987-2012, Larry Wall ... $ perl -MCGI -e 'print $CGI::VERSION' 3.59

In reply to problems with CGI module's command line debugging by 7stud

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.