UseModWiki | RecentChanges | Preferences

Functions : GetParam /Code

General Description of function:

Short little function for retrieving configuration and CGI query values. It first attempts to get a result from the CGI request. If that value is not present, it attempts to get a result from the UserData (which stores user preferences). In neither of these sources provide a value, it returns the default in the second parameter.

Given input


Returns results


Uses variables


Flow of Control of function:

Subtleties in code

One subtlety worth noting. CGI.pm has a feature utilized here. If you call GetParam("keywords", ""), you will get SomePage when the url looks like http://www.wikiserver.org/wiki.pl?SomePage

Global variables:

Special terms to describe function's actions



Fixes to bugs in code:

fixed code

Suggestions to improve code:

Just as a style point, why pass the default in the second parameter when you could just return undef if you can't set it, and then call as

$foo = &GetParam("foo") || $default;
? The way it's done at the moment, it's not immediately clear what the second parameter is for. I thought it was a get-set method to start with. This new suggestion is self-documenting.

suggested code

Sample output from function:

actual output

back to Functions

UseModWiki | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited January 15, 2008 6:04 pm by MarkusLude (diff)