CGI.pm: procedural vs. OO 
Author Message
 CGI.pm: procedural vs. OO

CGI.pm offers the choice of either a procedural or an OO interface.
Is there, in general, a compelling reason for choosing one over the
other?

Thanks!

G



Sun, 08 May 2005 00:26:50 GMT  
 CGI.pm: procedural vs. OO

Quote:

> CGI.pm offers the choice of either a procedural or an OO interface.
> Is there, in general, a compelling reason for choosing one over the
> other?

No.

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Sun, 08 May 2005 02:02:08 GMT  
 CGI.pm: procedural vs. OO

Quote:

> CGI.pm offers the choice of either a procedural or an OO interface.

I believe you mean function-oriented vs. object-oriented.

Quote:
> Is there, in general, a compelling reason for choosing one over the
> other?

Do a Google Groups search for "CGI.pm function-oriented vs object-oriented
style". You'll find this was discussed in clpm on 07May1999.

Cheers.

Bill Segraves



Sun, 08 May 2005 02:47:38 GMT  
 CGI.pm: procedural vs. OO
On Nov 19, William Alexander Segraves inscribed on the eternal scroll:

Quote:
> > Is there, in general, a compelling reason for choosing one over the
> > other?

> Do a Google Groups search for "CGI.pm function-oriented vs object-oriented
> style". You'll find this was discussed in clpm on 07May1999.

Yes, it seems a fair discussion:

http://groups.google.com/groups?threadm=m16764wnjx.fsf%40halfdome.hol...

The function oriented style may seem less to type, as long as you
import the functions.  But then there could be the risk of your own
routines clashing with CGI.pm function names.

If you don't import the functions, then you have to "CGI::" them
explicitly, so the brevity vis a vis "$q->" is lost  ;-)

I personally haven't ever felt a need to have more than one CGI
object in my script, so the function calls do the job just fine for
me.   YMMV.



Sun, 08 May 2005 04:23:08 GMT  
 CGI.pm: procedural vs. OO

Quote:

> CGI.pm offers the choice of either a procedural or an OO interface.
> Is there, in general, a compelling reason for choosing one over the
> other?

It's your choice :-) Usually there's no need for the OO interface.
But you can make some nifty tricks with the OO interface, e.g. adding
or changing query parameters for a self-link:

use CGI;
my $q = new CGI;
my $qq = new CGI $q->query_string;
$qq->param("anotheroption","value");
print $qq->query_string;

Regards,
        Slaven

--

    BBBike - route planner for cyclists in Berlin
    WWW version:                           http://www.bbbike.de
    Perl/Tk version for Unix and Windows:  http://bbbike.sourceforge.net



Sun, 08 May 2005 03:58:47 GMT  
 CGI.pm: procedural vs. OO

Quote:

> CGI.pm offers the choice of either a procedural or an OO interface.
> Is there, in general, a compelling reason for choosing one over the
> other?

The choice depends on what you are doing with it.  For most uses, the
functional interface is fine, and it is simpler for generating HTML.  Some
other modules such as HTML::Template benefit from using the OO interface;
for example you can use the CGI parameters as the HTML::Template parameters.  
CGI.pm has been designed so that it is also possible to use both forms in
the same program.

--
EBC



Sun, 08 May 2005 11:07:04 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. CGI.pm functions vs OO

2. CGI.pm vs. Base.pm

3. CGI-modules vs. CGI.pm

4. CGI.pm :: OO or not?

5. cgi-lib.pl vs CGI.pm?

6. cgi-lib.pl vs CGI.pm

7. cgi.pm .vs. cgi-lib.pl

8. Libbent: File.pm and Error.pm: OO File-I/O with error checking

9. Libbent: File.pm and Error.pm: OO File-I/O with error checking

10. vvp:CGI.pm printing vs executing statments?

11. CGI.pm and POST vs GET methods

12. CGI.pm vs. mac characters

 

 
Powered by phpBB® Forum Software