:::::::::::::: hello.cgi :::::::::::::: #!/usr/bin/perl use strict; use CGI ':standard'; #use CGI qw(:standard); #use CGI qw/:standard/; print header(); print start_html('Hello World'); print h1('Hello World'); print end_html(); exit ;:::::::::::::: hello-print.cgi :::::::::::::: #!/usr/bin/perl use strict; use CGI ':standard'; #use CGI qw(:standard); #use CGI qw/:standard/; print header(), start_html('Hello World'), h1('Hello World'), end_html(); exit; :::::::::::::: hello-oo.cgi :::::::::::::: #!/usr/bin/perl use strict; use CGI; my $cgi = new CGI; print $cgi->header(); print $cgi->start_html('Hello World'); print $cgi->h1('Hello World'); print $cgi->end_html(); exit :::::::::::::: hello-oo-print.cgi :::::::::::::: #!/usr/bin/perl use strict; use CGI; my $cgi = new CGI; print $cgi->header(), $cgi->start_html('Hello World'), $cgi->h1('Hello World'), $cgi->end_html(); exit; ;:::::::::::::: name.cgi :::::::::::::: #!/lusr/bin/perl -T use strict; use CGI qw(:standard); print header(), start_html('Hello'), start_form(), "Enter your name: ", textfield('name'), submit(), end_form(), hr(), end_html(); exit; ;:::::::::::::: name-print.cgi :::::::::::::: #!/lusr/bin/perl -T use strict; use CGI qw(:standard); print header(), start_html('Hello'), start_form(), "Enter your name : ", textfield('name'), "
", "Enter your address: ", textfield('address'), "
", "Enter your phone : ", textfield('phone'), "
", submit(), end_form(), hr(); if (param('name')){ print "Name = ", param('name'), p(); } if (param('address')){ print "Address = ", param('address'), p(); } if (param('phone')){ print "Phone = ", param('phone'), p(); } my @params = param(); print "@params"; my $name = param('name'); my $address = param('address'); my $phone = param('phone'); print h2("$name\n$address\n$phone"); print end_html(); exit :::::::::::::: dynamic.cgi :::::::::::::: #!/lusr/bin/perl -w use strict; use CGI ':standard'; if (param()){ # we have parameters, so process the form data 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 { # no parameters, so build the form 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(); }