Brethern, I'm puzzled by some behavior I see in the debugger. When I require a file, it doesn't behave as I expect. In detail –

I'm using CGI::Pretty to build screens for editing a data structure. On certain inputs, this was failing with an unhelpful message. To debug it, I wanted to run the program from the line debugger, so I could see the calling stack and so forth. But to re-create the error, I needed to call the cgi script with the same POSTDATA parameters.

So I wrote a small function that wrote all the 'param' parameters to a file:

print "#/usr/local/bin/perl\n"; foreach (param()){ print ("param('$_' , '", param($_), "'\n");}
which, as I intended, wrote a file that looked like
#/usr/local/bin/perl param('p1', 'v1'); param('p2', 'v2');...
I executed the script in the debugger and executed
DB<1> require "mydebugparam.pl" DB<2> x param()
To my surprise, no parameters had been set by reading in mydebugparam.pl. So, hacking on, I wrapped all the param calls in a function definition. I modified the code so it printed out something of the form:
#/usr/local/bin/perl sub sn{ param('p1', 'v1'); param('p2', 'v2');...}
Now I performed
DB<1> require "mydebugparam.pl" DB<2> sn() DB<3> x param()
and saw the parameters set as I had intended.

Why didn't require-ing the param statements work, while wrapping them in a function def did?

Am I going about this all wrong? Is there an easier way to be debugging cgi forms that have large numbers of POSTDATA params?

thanks
throop


In reply to CGI Params in a scratch file for debugging by throop

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.