object Perl
Craig Freter
freter at freter.com
Mon Aug 9 14:53:29 CDT 1999
At last weeks meeting we discussed the difference between using the CGI
module with either the object interface, or the procedural interface. I
created a simple CGI using both the object interface and procedural
interface of CGI.pm.
I think the procedural interface is easier to read. Let find out what
the rest of you think.
First the object interface.
# import nothing
use CGI;
# create CGI object
my $cgi_obj = new CGI;
# call CGI object methods inside of print function
print
$cgi_obj->header,
$cgi_obj->start_html(-title => 'Baltimore Perl Mongers',
-BGCOLOR => 'white'),
$cgi_obj->h1('Baltimore Perl Mongers'),
$cgi_obj->hr,
$cgi_obj->h3('Perl Mongers is a not-for-profit organization
whose mission is to establish Perl user groups'),
$cgi_obj->end_html;
...and now the procedural interface.
# import functions in tags 'standard' and 'html3'
use CGI qw(:standard :html3);
# use CGI functions inside of print function
print
header,
start_html(-title => 'Baltimore Perl Mongers',
-BGCOLOR => 'white'),
h1('Baltimore Perl Mongers'),
hr,
h3('Perl Mongers is a not-for-profit organization
whose mission is to establish Perl user groups'),
end_html;
--
All that is complex is not useful,
and all that is useful is simple.
-- Mikhail Kalashnikov
More information about the Baltimore-pm
mailing list