Behind the scenes, CGI.pm does the same, despite the styles. The functional interface actually uses a secret object that you do not see.
For many small CGI projects, you probably will never need more than one CGI object at a time, so the functional interface is fine. This may be a more common style, but only because most people make small scripts for very specific tasks. If you have many other things, you may not like the fact that CGI.pm imports a long list (and long) of function names into your script. Some function names may interfere with other modules that you want to import.
However, I always use an object-oriented interface. I donβt need to worry about name collisions, and this is obvious when a method comes from the moment you see its object. It is also easy to pass an object as arguments to other parts of large applications, etc.
Some people may complain about additional typing, but this has never been a slow part of programming for me. I have been doing Perl for a long time, and I am not against syntax. However, I use only CGI to input input and possibly send output. I do not interfere with any HTML material.
When he talks about one CGI.pm object at a time, he refers to access to the input. For example, if you read STDIN, another CGI.pm object will not be able to read this. However, you can have as many objects as you like. They simply will not share the data, and the first receives all the POST data.
In fact, you can use the mixture. You can import some things, for example :html , but still use the OO interface to process the input.
brian d foy
source share