Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Tao Perl Ching - The Scripture of the Way of Perl

by archen (Pilgrim)
on Dec 18, 2004 at 17:14 UTC ( #415874=note: print w/ replies, xml ) Need Help??


in reply to Re: Tao Perl Ching - The Scripture of the Way of Perl
in thread Tao Perl Ching - The Scripture of the Way of Perl

The latter unfortunately is interface-wise compatible with CGI; and I don't like that interface much

Why is that? Not to troll, I'm just curious. Personally I only use CGI::Simple + HTML::Template which is about 50% faster than useing CGI.pm in most of my circumstances.


Comment on Re^2: Tao Perl Ching - The Scripture of the Way of Perl
Re^3: Tao Perl Ching - The Scripture of the Way of Perl
by Juerd (Abbot) on Dec 18, 2004 at 17:38 UTC

    Why [do you not like CGI.pm's interface much]?

    Mostly because it's terribly inconsistent. Why is is Vars ucfirst, but param all lc? Why are some, but not all words in names separated by underscores? Another thing I absolutely do not like is the prefixed minus for arguments. Perl is not a shell, so stop trying to look like one. And even then: no, that minus doesn't make it look like shell command line arguments. Of course, the minuses are needed because CGI.pm mixes positional and named arguments.

    Yes, CGI::Simple is much faster than CGI.pm. And that's a good reason to use it. I use it often. Doesn't mean I like the interface. I understand that it wants to be compatible with CGI.pm.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      There are good reasons for many of those things. Vars begins with an upper-case V because vars is a Perl reserved word. All the other functions use lower-first casing, so better to make the one exception than change the entire module's syntax.

      The prefixed minus is familiar to me from another language (I can't remember which, now) -- it's not an attempt to make them look like shell arguments, but rather a very common style; I suspect the author(s) of CGI.pm were used to using and seeing that style for named parameters. Because of this, when my functions accept named parameters, I use Params::Validate to normalize the keys, allowing but not requiring the prefixed minus.

      Anima Legato
      .oO all things connect through the motion of the mind

        There are good reasons for many of those things. Vars begins with an upper-case V because vars is a Perl reserved word.

        It may be a reason, but it certainly is not a GOOD reason. It's an awful one. If the name you want is taken, then invent another name! Don't find alternative ways to write the same thing for that WILL cause confusion and WILL look ugly.

        It is not even true. "vars" is not a reserved Perl word. There is a module called vars, but use is not the context. The context is a sub/method name, and you can without any trouble call that &vars:

        use strict; use warnings; sub vars { 1 + 1 } print vars; print main->vars;

        I use Params::Validate to normalize the keys, allowing but not requiring the prefixed minus.

        The only reason a minus is needed or wanted is wanting to allow a combination of positional and named arguments. Allowing a minus is nice for people who insist on consistent style (but those people should prepare for re-coding CPAN entirely), but IMnsHO it's a waste of CPU cycles to look for them.

        Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://415874]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2014-12-26 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (168 votes), past polls