Appendix D. mod_perl
Example Code
The following are a few code examples that were omitted from Chapter 17, “mod_perl,” in the interests of brevity.
mod_perl
Form Handler Code
In Chapter 17, code was presented that would parse the contents of a HTML form, or the contents of URL “command-line” arguments in ?key=value&key=value
syntax.
The portion of this code that does the actual form parsing is the single line that follows:
my %form = $r->method eq 'POST' ? $r->content : $r->args;
This line uses the Perl ? :
syntax, which functions exactly like an if/else
clause. This syntax allows for a simple if/else
clause to be expressed in one line, as shown in the example. If written out fully, the statement would look like the following block:
my %form; # Declare ...
Get Apache Administrator's Handbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.