Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Now that we have somewhat functional code, it is still broken for two reasons.

The first has to do with CGI's attempts to overload the param function with every possible behaviour. What happens if your form has an input variable named "-name"?

The second has to do with Perl's list versus scalar context. What happens if your form sent back multiple values with the same name?

Here is more robust code, using the functional interface (easily translated into the OO interface):

foreach my $name (param()) { my @values = param($p); s/\*//g foreach @values; param( -name=>$name, -values=>\@values ); }
And people wonder why I prefer to avoid creating highly magical polymorphic interfaces? Note between merlyn and myself in 8 lines of code, with 5 different invocations of the param function, no two of them used the same part of the possible interface! (This is even true if you don't count the OO vs functional invocation issue.) People handle context pretty well, true, but there is a limit beyond which people start having problems. And when you mess up for this reason, it isn't very obvious that you did mess up, or what you did wrong!

In reply to Re (tilly) 2: form parsing by tilly
in thread form parsing by Rotomola

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-03-29 06:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found