Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

*.pm vs. *::Simple

by Zecho (Hermit)
on Oct 22, 2001 at 17:43 UTC ( [id://120517]=perlquestion: print w/replies, xml ) Need Help??

Zecho has asked for the wisdom of the Perl Monks concerning the following question:

(substitute CGI for any module with a ::Simple counterpart)
Can someone explain the differences in XXX.pm XXX::Simple etc, Say for instance, CGI.pm. Is CGI::Simple, a smaller subset of the same usage terms? Could it be looked at as: CGI::Simple is the basic structure, with CGI.pm being the complete unabridged and expanded compilation? I know html rather well I think (having used it for a number of years) and using CGI would seem to make some things easier for me, but I am right smack in the middle of learning perl, and now EZDBI (for a current project). From what I have gathered, CGI::Simple is quite easy to understand and use. Am I wrong in assuming this? How confused am I going to get trying to add another something to the list of things I'm already attempting to commit to memory? And what are the pros/cons of CGI.pm vs. CGI::Simple ?

Replies are listed 'Best First'.
Re: *.pm vs. *::Simple
by davorg (Chancellor) on Oct 22, 2001 at 17:54 UTC

    Well, having just searched CPAN, I can't find any reference to a module called CGI::Simple. That would seem to me to be one good reason for not using it.

    The CGI module can be a simple or as complex as you want it to be, and I think it would be a shame to invest time learning CGI::Simple and then eventually find that it doesn't do something that you need. You'd then have to start again, learning how to use CGI.

    Another advantage with CGI.pm is that is a part of the standard Perl distribution, so you can guarantee that you'll find it installed everywhere.

    All in all, I can't think of any good reason to use any module in preference to CGI.pm.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."

Re: *.pm vs. *::Simple
by tachyon (Chancellor) on Oct 22, 2001 at 18:15 UTC

    CGI.pm is a big module. It does a lot. It is part of the standard distro. It is well tested. It is well documented. It will do more than you want. Does this make it

    >>> bloated? <<<

    Perhaps technically yes but in that case all modules/libraries are bloated. Does it only load the code that you use via a custom implementation of self loader - more or less yes. Will you see any practical speed benefit using anything else - probably not.

    CGI.pm don't leave home without it.

    cheers

    PS some of the other offerings on CPAN are good. Some are not. Last time I bothered to mention this to one of the authors of a rather bad module I did not get a reply. In contrast Lincoln Stein, who mostly wrote CGI.pm, will likely reply within hours if you have a CGI.pm problem. Admittedly he is likely to explain that the module is fine and it is your code that sucks but that is because CGI.pm is so well tested ;-)

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      The bloat wouldn't bother me as much if it was relevant to the Common Gateway Interface, but no, it's mostly HTML related.

      The extra HTML functions should probably go into another module called something like HTML::OO, HTML::Funk or HTML::whatever. Or you can be really sneaky and put it in CGI::HTML.

      If not, then when will we see XML,WML related code bloat CGI.pm even more ?

      Tiago
Re: *.pm vs. *::Simple
by chromatic (Archbishop) on Oct 22, 2001 at 20:06 UTC
    Unofficial (almost unwritten) CPAN convention explains them as:
    ::Simple Simple/basic interfaces to more complex modules ::Lite Lightweight implementations of protocols etc
    There's some overlap here. (Some people think SOAP::Lite should rather be SOAP::Simple.)
Re: *.pm vs. *::Simple
by thinker (Parson) on Oct 22, 2001 at 18:28 UTC
    Hi Zecho,

    The only module I can find on my machine with a ::Simple counterpart is LWP, which has LWP::Simple.

    Here is the explaination that the author of that module gives.

    DESCRIPTION

    This interface is intended for those who want a simplified view of the libwww-perl library. It should also be suitable for one-liners. If you need more control or access to the header fields in the requests sent and responses received you should use the full object oriented interface provided by the LWP::UserAgent module.

    I guess what this means is that Module::Simple presents, what is in the opinion of the author, a simple interface to his/her module

    cheers

    thinker
Re: *.pm vs. *::Simple
by thunders (Priest) on Oct 22, 2001 at 18:45 UTC
    Another misconception that needs to be addressed is that Thing.pm does not necessarily have very much to do with Thing::OtherThing or Thing::Simple or Thing::Whatever in each of those cases you have a module called OtherThing.pm or Simple.pm or Whatever.pm in a folder called "/Thing". These modules may or may not require you to have Thing.pm installed. I don't see CGI::Simple in my standard distribution, so I doubt that it is supported by the creator of CGI.pm. My best advice to you is to read the documentation for CGI.pm and for CGI::Simple, and use whichever makes sense to you.
Re: *.pm vs. *::Simple
by jmcnamara (Monsignor) on Oct 23, 2001 at 04:06 UTC

    I think that the authors of the ::Simple modules deserve some credit for identifying the core functionality of a module and concentrating on that. They deserve real credit if they manage to "keep it simple".

    For example, over two years ago I was developing an Excel library in C when I came across a simple hack to generate minimal Excel binary files with very little code. At the time I was using Perl to generate CSV file for importation into Excel and thought that I could try to produce a binary file instead. To my surprise it worked out very well: mainly due to, my now beloved, pack() function.

    I posted the code to comp.lang.perl.modules in response to a question. It was about 200 lines of code and comments. After that I rolled it into a module and posted it to CPAN as Spreadsheet::WriteExcel. It was about 600 lines including POD. And it was very simple: it wrote text and numbers to a single worksheet in an Excel workbook. This was all that I needed it to do and I was quite happy with it.

    After a while people started to write to me and say that it would be nice to have multiple worksheets. From my past experience with the C library I knew that it would be difficult to create a cross-platform solution without the appropriate Windows libraries. However, I hacked away at it and after 3 months I had a solution.

    After that I received a steady stream of requests to add formatting, hyperlinks, formulae, functions, page setup and images. So I included those as well and now, almost two years later, Spreadsheet::WriteExcel is over 7000 lines of code, is comprised of 10 modules, uses Parse::RecDescent, uses pack() 300 times and has over 40 pages of documentation.

    But what prompts me to write this is that recently a Spreadsheet::WriteExcel::Simple module was uploaded to CPAN. It subclasses Spreadsheet::WriteExcel to provide more or less the functionality of the first version that I wrote. When I spoke to the author, Tony Bowden, about it he said that it was inspired by a client who just couldn't deal with Spreadsheet::WriteExcel.

    In many ways it would have been nice to have called it a day after the first 200 line version and lay claim to the clarity and resolve of the ::Simple authors. Because, even if peoples expectations aren't simple, code can be.
    --
    John.

Re: *.pm vs. *::Simple
by demerphq (Chancellor) on Oct 22, 2001 at 17:48 UTC
    Good question. Ive wondered the same thing too. Hopefully a guru will step in and explain a bit. The HTML and CGI and CGI3 and cousins are a large and confusing bunchof modules without direction as to where to start.

    Thanks for asking Zecho.

    Yves
    --
    You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)

Re: *.pm vs. *::Simple
by rrwo (Friar) on Nov 08, 2001 at 09:44 UTC

    XXX::Simple.pm could mean many things:

    • A simpler way of doing XXX, but not necessarily the same way of doing it that XXX.pm does, or with all of the functionality of XXX.pm;
    • A simpler interface to XXX.pm, not necessarily with all of the functionality;
    • A simple implementation of XXX, where they may not even be an XXX.pm;

    Or combinations of the above.

    Simply put: a *::Simple module is either a simpler interface, or it does something simply.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://120517]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-29 11:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found