in reply to Re: form processing problem
in thread form processing problem

Second method, the object-oriented method, in which you work with a reference to an object of CGI
And I've never really seen an advantage to that, except to make CGI programming look harder than it needs to look for the beginning programmer.

Apparently, Lincoln agrees. The latest releases of CGI.pm documentation emphasize the imported version, rather than the object version. Makes the manpage look a whole lot cleaner.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^3: form processing problem
by manav (Scribe) on Mar 24, 2005 at 16:22 UTC
    Object oriented approach makes programmers who are conversed with C++ think that they know what's going on... ;)


    Seriously, the given example notwithstanding, I've seen lots of code with
    use CGI qw/:standard/ ; print redirect('http://www.nowhere.to.go') ;
    I mean, Isnt it useless to clutter up your namespace with imported symbols just to use next-to-nothing from it??


    Manav
      Well, in that case, I'd advocate "use CGI 'redirect'", actually.

      But really, at some point, it becomes "the cost of my time to optimize the import or use OO invocations" vs "the cost of 5 hits a minute on a webserver". If the trade is against 50 hits a second, your argument holds water, but at 5 hits a minute (fast even for the majority of operations), who cares? {grin}

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        Well, in that case, I'd advocate "use CGI 'redirect'", actually.

        Of course ;) Thats why I said, "given example not withstanding".
        Although have never been involved in such a trade-off, I guess everybody does expect 50 hits a second on his website a second when he/she is designing it.

        The real reason for posting here was to get the author to know (and probably keep-in-mind) that there is more than one method there. I guess referring to the man-page might also have been a good option.....



        Manav
Re^3: form processing problem
by Tanktalus (Canon) on Mar 24, 2005 at 21:46 UTC

    First off, when talking about general advantages of OO vs import-the-world (or import-what-you-need), I'm not sure that we could all agree on a single expert (possibly including Larry). And, even if we could, I'm not sure that Lincoln would necessarily be that expert ;-)

    Secondly, the CGI documentation still states:

    The examples in this document mainly use the object-oriented style.
    It's not entirely clear that Lincoln has a preference.

    Personally, I prefer the OO style to keep things clear in my head where things are coming from. But maybe that's just me. :-)

      when talking about general advantages of OO vs import-the-world
      Uh, I wasn't making this a general conversation. I was talking specifically about CGI.pm and the typical use (a singleton object, and with people who probably don't want to grok Perl's OO).

      Please don't light up a different fire. This one fans well enough. {grin}

      Secondly, the CGI documentation still states:
      The examples in this document mainly use the object-oriented style.
      That's a vestigial text. Look at the examples in the rest of the doc. They've been almost entirely converted to import style. This happened quite recently.
      It's not entirely clear that Lincoln has a preference.
      It's very clear to me. I've seen Lincoln talk at conferences. In fact, I even filled in for him once. His slides never use the OO form. That's why I wasn't surprised when he finally changed the manpage.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.