Hi monks, I read the CGI.pm: 'http://search.cpan.org/~lds/CGI.pm-3.43/CGI.pm#USING_THE_FUNCTION-ORIENTED_INTERFACE', and then try to use function-oriented interface to run the cgi example as the manual shows:
use CGI qw/:standard/; print header, start_html('Simple Script'), h1('Simple Script'), start_form, "What's your name? ",textfield('name'),p, "What's the combination?", checkbox_group(-name=>'words', -values=>['eenie','meenie','minie','moe'], -defaults=>['eenie','moe']),p, "What's your favorite color?", popup_menu(-name=>'color', -values=>['red','green','blue','chartreuse']),p, submit, end_form, hr,"\n"; if (param) { print "Your name is ",em(param('name')),p, "The keywords are: ",em(join(", ",param('words'))),p, "Your favorite color is ",em(param('color')),".\n"; } print end_html;
Yes, the cgi scripts run well and show the expected result, however, I see a lot of warnings at 'error.log':
root@Sparta:/var/www/cgi-bin# tail -f /var/log/apache2/error.log CGI::param called in list context from /var/www/cgi-bin/test.cgi line +22, this can lead to vulnerabilities. See the warning in "Fetching th +e value or values of a single named parameter" at /usr/local/share/pe +rl/5.18.2/CGI.pm line 404.
I used object-oriented style before, and this is my first experience to function-oriented style. I googled for this question and just found the items according to 'object-oriented style'. Would you please help me explain the warning message at log? and how to fix it as function-oriented style? Thanks, PH

In reply to CGI problem: USING THE FUNCTION-ORIENTED INTERFACE by PhillipHuang

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.