sub ReadDNo(\%)
{
my $in = shift(@_);
if(!defined(${$in}{'d_no'}))
{
return 1;
}
my ($dno) = (${$in}{'d_no'} =~ /^(\d+)$/);
return $dno;
}
*Since i am setting the values i am not worried about excess spaces, though i could add it.
This will run, and the default is to display the summary, which works great if it is displayed as: www...../script.cgi but if i run what should be the equivalent of: www...../script.cgi?mode=summary it doesn't work. Basically all of my mode values no longer work, while if i use a constant value my $d_no = 7; they all display fine, but the $d_no is always 7. The $d_no value displays correctly in the address bar, so i my values are found correctly inside of my edit, input, etc methods, but it is not displayed correctly.
Mode switching code just in case it helps:
if($mode eq 'input')
{
#input mode allows a new entry: display form
PrintFiles(%substitutions, "DLog.html");
}
elsif($mode eq 'submit')
{
if(my $error = saveData(%incoming))
{
$substitutions{'ERROR'} = $error;
PrintFiles(%substitutions, "DLog.html");
}
else
{
summary(%substitutions);
}
}
elsif($mode eq 'view')
{
#details/edit details of a single entry:
edit(%substitutions);
}
elsif($mode eq 'summary')
{
summary(%substitutions);
}
else
{
#exit on any other input mode
die('Error: Unrecognized Mode');
}
My question basically boils down to:
Is there a way to use the value from the address bar for $d_no instead of the one my cgi is apparently not getting, or is there a better way to deal with this? Any ideas are welcome.
2) I have a comments area which (should) handle multiple words, i've looked around and it seems like i need to use \g, but there isn't a single good explanation on how to read all the words. Technically i don't need to read each word, just the entire text as a whole from the textarea.
I had been using something like this:
sub ReadComments(\%)
{
my $in = shift(@_);
if(!defined(${$in}{'comments'}))
{
return '';
}
my ($comments) = (${$in}{'comments'} =~ /^\s*(\w+)\s*$/);
return $comments;
}
but this only works for a single word, any suggestions?

New Topic/Question
Reply



MultiQuote



|