Mega Code Archive

 
Categories / Perl / CGI
 

Using param() function to get parameter

#!/usr/bin/perl -w use strict; use CGI ':standard'; if (param()) {     my @params    = param();     my $firstname = param('firstname') || 'you have no first name!';     my $lastname  = param('lastname')  || 'you have no last name!';     print          header(),         start_html(             -title   => 'Welcome!',       -text    => '#520063'         ),         h1("Hello, $firstname $lastname!"),         end_html(); } else {     print     header(),   start_html('A Simple Form'),   h1('Please Enter Your Name'),   start_form(),   'First name: ',   textfield(-name => 'firstname'),   br(),   'Last name: ',   textfield(-name => 'lastname'),   br(),   submit(),   end_form(),   end_html(); }