siddheshsawant has asked for the wisdom of the Perl Monks concerning the following question:

Hello once again !!!!

I am writing a web application using Perl CGI script.I am giving pp_branch,start_date,end_date and controller as a user input from the web page.I am handling a case when the end date text box is empty.I am writting a following code to convert user input to the hash references.

$user_input->{pp_branch} = param('pp_branch'); $user_input->{host_name} = param('host_name'); $user_input->{controller} = param('controller'); $user_input->{start_date} = param('start_date'); if (defined param('end_date')) { $user_input->{end_date} = param('end_date'); } else { $user_input->{end_date} = param('start_date'); }

Kindly tell me am I handling end_date text box empty in right way?? Because I am not getting the desired o/p.I am handling end_date text box empty case.


Thanks in advance !!!!

Replies are listed 'Best First'.
Re: Question on CGI
by jethro (Monsignor) on Mar 09, 2010 at 23:07 UTC
    Probably an empty text box generates a defined parameter end_date with an empty string ("") as contents.

Re: Question on CGI
by pemungkah (Priest) on Mar 09, 2010 at 23:04 UTC
    Can't be sure: we don't know (for instance) what $user_input contains, and making assumptions about that wouldn't help you solve this.

    Do you mean by "I am not getting the desired o/p. I am handling end_date text box empty case" that you are getting the output you want for the empty case but not for the other one, or that the empty case isn't being handled right? I assume you mean the second ... but I still can't tell from what you've posted where the problem is. Need more context.

    What is the smallest piece of code that runs and exhibits the aberrant behavior? (By the way, once you have that, you have a test for this bug, and the start of a test suite!)