go ahead... be a heretic | |
PerlMonks |
Re: Perl modules (was: Re: Begginer's question: ...)by haukex (Archbishop) |
on Jan 19, 2017 at 14:08 UTC ( [id://1179915]=note: print w/replies, xml ) | Need Help?? |
Hi predrag, I've partially changed the title of this node but am not sure if that is ok? Yes, changing the node title is ok, in this node I've also made a change to the title to shorten it a bit. See also How do I compose an effective node title? Note that if threads go too far off-topic, or if there are follow-up questions that are not directly related to the original question, often it's better to start a new thread (a good example being your question of how to specify which Perl version to use, which I've answered below). I would like to learn CGI scripting later this year and it is very useful for me to know that CGI module is not more recommended. Yes, there are several more modern web frameworks now: Plack, Catalyst, Dancer, Dancer2, and Mojolicious (all of these implement the new PSGI specification). All of these are good, in my personal opinion I like Mojolicious. Here is a tutorial for getting started with Mojolicious::Lite. ... separate Perl installations. Then, in scripts, I should address the version I want to use? A typical set-up would be to have the system Perl in a location like /usr/bin/perl, and to have one or more other Perl installations in e.g. ~/perl5/perlbrew (when using perlbrew). However, I normally* wouldn't recommend changing the shebang line ("#!/usr/bin/perl") to a specific installation, because that will likely not work when the scripts are copied to other machines. Instead, one would ensure that the environment variable PATH is pointing to the desired Perl installation (such as with "perlbrew switch perl-5.24.1", can be checked with the command "which perl"), and then in your scripts the shebang line "#!/usr/bin/env perl" will cause the perl currently in your PATH to be used. Changing the PATH to select a Perl installation also has the advantage that a command like cpan Module::Name will install to the selected Perl installation. Also, in your Perl scripts you can specify a minimum required Perl version with e.g. use 5.024; for Perl v5.24 (this has the advantage that the new default features of that Perl version are enabled). Is is uncommon and usually not necessary to specify "use exactly this version of Perl". * However, the aforementioned advice about the shebang line can change in the case of scripts uploaded to a server that you do not have control over. Some webhosts limit their customer's ability to use custom Perl versions, instead providing one or more Perl installations themselves, such as /usr/local/bin/perl5.16 or /opt/perl5.20/bin/perl. In such cases, it might be necessary for you to change the shebang line to point to a specific installation of Perl. for the server, is it recommended to have just that so demanding module or work with some others? 1nickt and hippo already discussed some of the pros and cons of this. The number of modules you have installed on a machine won't make a difference, only the modules your script uses will make a difference in the start-up time of the script. Traditional CGI scripts would get re-executed on every request to the web server, so start-up times on CGI scripts would make a difference, especially if they get many requests per minute. There are however more modern web servers in which the scripts keep running between requests, in which case the start-up times do not matter. Of course, if this is just a small web page on which you don't expect many requests, start-up times of the scripts may not matter much at all. Otherwise, it would be wise to consider ways to optimize, such as using one of the more modern implementations that keep the scripts running. Another approach might be to not re-generate the charts on every request, instead keeping them cached and only re-generating them when necessary, such as based on an interval or when the data changes. I would also ask You, if it is ok to sometimes send You a personal message, when I am not sure whether my reply to your post is interesting to others or not? Personal messages are ok, but note that they are limited in length. In general, anything related to Perl (including web interfaces with Perl) is on-topic here, so it is of interest :-) Posting publicly also means more people can learn from the discussions. Regards,
In Section
Seekers of Perl Wisdom
|
|