I'm writing a function that will list once all params passed to a CGI script, whether it be through a form sent with POST, the URL string, or both.
There are two functions for this:
param(): Despite the documentation, I have found this to read EITHER POSTed parameters from a form OR URL params only if there are no POST params.
On the other hand, url_param() will ever ONLY read params passed in through the URL string regardless of POST.
My function
sub post_and_url_param_keys{
if(url_param){
return [url_param, param];
}else{
return [param];
}
It can list all parameters if passed in with:
√ POST and URL params
√ POST params only
X URL params only (lists each key twice)
Is there a way to neatly fix this without having to check the name and value of each and every param pair for duplicates?
A slightly improve method would be to check if request_method() eq 'POST'. You may still get duplicate parameter names if you query string and post both contain the same parameter name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With