|
Posted by J. Gleixner on March 28, 2008, 11:36 am
Please log in for more thread options
Ela wrote:
>> In general, you just don't do that. If you want to put processing code
>> in separate files, just use those files from the same CGI program. IOW,
>> use modules. That's more efficient and less error prone than trying
>> to invoke stand-alone scripts from each other (not to mention that doing
>> that will probably not work out of the box for CGI scripts that read
>> POST data).
>>
>> HTH,
>> Joost.
>
> But in the sense of putting the search and fetch functions in the same cgi,
> how come results can be generated after accepting users' input parameters? A
> simple example based on my simplified codes will be appreciated~
>
> #!/usr/bin/perl
>
> use CGI qw(:standard);
>
> $query = new CGI;
No need to do that when using :standard. You can simply call
the methods and you can use one print for multiple values.
print header(),
startform(),
'Title: ', textfield(-name=>'title', -justification=>'RIGHT'),
submit(-name=>'button_name', -value=>'Get !'),
endform();
No idea what the 'justification' attribute for an input element does.
>
> print $query->header;
>
> print $query->startform;
> print "Title: ",$query->textfield(-name=>'title', -justification=>'RIGHT');
>
> print $query->submit(-name=>'button_name', -value=>'Get !');
> print $query->endform;
if ( my $title = $query->param('title') )
{
# possibly validate what's in $title before using it..
# use $title for something
# print the results as HTML
}
> print $query->end_html;
>
> #the following print can be executed successfully but the resultant page is
> just wield....
> print $query->param('title');
> print "<BR>";
>
>
|