Question

I am a beginner for the perl programming and want to clear some doubts in my mind.

  1. Since for the development I am not using CPAN and writing the code for all the things. Why to use CPAN? What is CPAN?

  2. When to use framework and how can it help in beginners coding.

and also If i want to develop my website using framework so which framework is easy to get and simple but efficient.

P.S : My question is related to perl programming

Was it helpful?

Solution

CPAN is a collection of Perl Modules. You can search for modules e.g. via the metacpan page. For each module, you can read through the documentation to see if it can help you. If you want to install it, go to the command line and type cpan Interesting::Module. After the module is installed and tested, you can use it in your programs.

This usually looks like

use Interesting::Module 'interesting_function';

my $answer = interesting_function(42);

Code reuse is good, because you have to write less complicated code yourself: Others already did it. Some things are difficult to do correctly – using a module means less stuff to think about. But you should always read the documentation of a module in order to apply it correctly.

As an example, people used to write CGI programs with their own URL decoding. But that is unneccessarily repeated code! There are various modules that have helper functions to do exactly that, and can correctly parse query strings. The same holds for databases – properly using a module makes it easier to avoid SQL injection vulnerabilities.

Of course, serious web development has moved beyond CGI. In Perl the following web app frameworks are well-known:

If you just want to try out one of these frameworks, then Dancer is probably more lightweight and easier to use than the others.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top