Very good answer Octavian Rasnita :)
On Fri, Feb 7, 2014 at 2:00 PM, Octavian Rasnita <orasn...@gmail.com> wrote: > CGI is just an interface between a program and a web server. > Other newer interfaces are fastcgi, fcgid, mod_perl, psgi... > > Using another interface than CGI has some advantages and some > disadvantages. > The main advantage is that the programs are persistent, so they are ran > once, usually when the web server starts, then they respond very fast to > HTTP requests. > The disadvantage is that they are a little more complicated than just > using CGI, plus that they consume some more memory. > > If you need to create a public web site that should always respond as fast > as possible, it is definitely required to use the modern interfaces, > preferably psgi. > If you need to create very small scripts just for internal use, with no > relations among them, so no central authentication/authorization for > example, and if they are not accessed by very many users in a day and it is > OK if the users wait 2 more seconds to open the page, then you can use CGI > with no problem. > The CGI scripts are not persistent, so they are loaded/compiled/executed > each time they are accessed with an HTTP request. If you change something > in a CGI script, you don't need to stop/start it after you do the change. > > Using web frameworks is another story. > If you need to do very very simple and dirty scripts that do very simple > things and return a very simple web interface, then you can create them > without using higher level modules like an ORM, a templating engine, a form > manager. > > If the programs are a little bigger, and if they need to be easily > maintainable or if the web interfaces they need to create are a little more > complex, then it is better to use that kind of module, and separate the > Perl code and the HTML, Javascript, CSS code in distinct files. > > If you need to use those modules and you actually want to create a web > application, then it is easier if you use a web framework. The most used > Perl web frameworks these days are Catalyst, Dancer and Mojolicious. > They help you to organize the application in a way that makes it easy to > maintain on long term. > > You can use the web frameworks with any interface you like (if the > framework supports it), for example you can use a Catalyst - based web app > with the CGI interface, but because CGI interface needs to load the entire > application on each request, and when using a web framework it usually > needs to load a lot of module, it works very very slow. > So usually when the application uses a web framework it also uses a > persistent interface like psgi or fastcgi or mod_perl. > > If the scripts are accessed only localy, if they are complex enough and > need to be easy maintainable and you want to use a web framework, you need > to choose among Catalyst, Dancer, Mojolicious, CGI::Application or other > Perl framework. > > For smaller projects that require very few features, Dancer and > Mojolicious Lite may be better than Catalyst because they are easier to > learn, but for bigger applications or applications that may become bigger > Catalyst is better. > > Also, if you know to use some Perl modules like an ORM like DBIx::Class, a > templating system like Template-Toolkit or others, Catalyst is better > because it is very flexible and lets you use what you want. > But if you don't know anything, Mojolicious may be better because it does > the things in its own way. It also allows you to use other Perl modules, > but the recommendations are always to use its standard way. > > So there is more than one way and you can choose depending on your needs. > > --Octavian > > ----- Original Message ----- > *From:* Robert Freiberger <rfreiber...@gmail.com> > *To:* begin Perl Beginners <beginners@perl.org> > *Sent:* Friday, February 07, 2014 8:30 AM > *Subject:* Newbie creating Perl web report > > Hello everyone, > > I'm somewhat confused on a topic of CGI vs a web frame work for creating > simple applications. I've been reading Beginning Perl by Ovid and seems > like it's recommend to use a frame work instead of the older method of CGI > module. > > Is frame works like Mojolicious or Flask the new recommended method for > creating web based tools or scripts? My goal is making some reports for > work that would stay internally but also apply what I learn to other > external side projects. > > Thanks, > Robert > > -- > Robert Freiberger > > -- Regards, Chankey Pathak <http://www.linuxstall.com>