Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^9: Begginer's question: If loops one after the other. Is that code correct?

by predrag (Scribe)
on Jan 14, 2017 at 17:01 UTC ( [id://1179571]=note: print w/replies, xml ) Need Help??


in reply to Re^8: Begginer's question: If loops one after the other. Is that code correct?
in thread Begginer's question: If loops one after the other. Is that code correct?

Hauke D, I simply can't say enough thanks to you. I can only hope that all this is useful to you too and maybe it is true, because as I know, in pedagogy they say the best way for learning is to teach someone (people) and the inverse: teaching is considered as the best way for learning.

I've already had installed cpanm, and with its help, I've succesfully and easy instaled these two modules you used in the code. They are really powerful, and of course, I constantly convince myself how CPAN is huge and powerful

Just tried your code and it works, completely well. Excellent. I see the code does two things, and I have to look at that more detailed and make many tests. I am really excited and happy but you should remember that I am still a beginner and need a time to settle knowledge acquired here

It is fantastic you showed me into IDN encoding. As I've wrote last time, I've recently learned something about IDN and got ACE string on my Cyrillic domain on our national domain service web page form, so I will try to check it with your script now. So happy!

You mentioned "ISO/R 9" and it is my shame, at this moment I can't tell you if it is what I use. It seems I am a bit more confused and a bit tired today that can't answer now. Anyway, you brought me to the solution of so important things for my project

Websites with Cyrillic domain name are rare and I've noticed on the web that these mostly have the rest on the url on Latin, but it seems I will have in Cyrillic, wow!

  • Comment on Re^9: Begginer's question: If loops one after the other. Is that code correct?

Replies are listed 'Best First'.
Re^10: Begginer's question: If loops one after the other. Is that code correct?
by haukex (Archbishop) on Jan 17, 2017 at 12:23 UTC

    Hi predrag,

    I can only hope that all this is useful to you too and maybe it is true ... teaching is considered as the best way for learning.

    Yes, part of the reason I wrote the code above is to satisfy my own curiosity :-)

    I've already had installed cpanm, and with its help, I've succesfully and easy instaled these two modules you used in the code.

    I just wanted to point out that since CPAN is huge, there are also a lot of modules that might not be well-tested or have other problems. In this node I wrote about some ways to tell which modules are good and which might not be.

    Also, another thing is that it's usually recommended to avoid modifying the Perl that comes with your Linux system. The system Perl is usually managed by the system's package manager, and there might be programs that require those specific versions of Perl or its modules. Also, installing Perl modules into the system Perl with both the package manager and CPAN can sometimes lead to breaking the installation. If you've already installed modules into your system Perl, then as long as your system keeps running normally you don't need to worry, but I would recommend installing a separate version of Perl locally so that you can avoid touching the system Perl at all when installing modules. Another advantage of installing a separate version of Perl is that you can always have the latest version. The program perlbrew makes this very easy.

    Regards,
    -- Hauke D

      Hi Hauke D,

      I've partially changed the title of this node but am not sure if that is ok? Probably I had to change it once before, when new question about converting to Cyrillic appeared but I wasn't sure if I could do that the right way. I wonder if it is possible to do now and if yes, should I do that?

      Thanks for the links. 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.

      I will have in mind the possibility to have separate Perl installations. Then, in scripts, I should address the version I want to use?

      Two days ago, I've installed the old Ubuntu version (12.04) on my Virtual Box and there is a little higher Perl version then I have on other systems. I was surprised with so many Perl modules in Ubuntu Software Center and suppose just a part are CPAN but others are not. So, I've installed several through this Center and just few through CPAN. Then later, I've read in your post about recommendation to avoid modifying the Perl in the system and about installing modules two ways.

      I think my systems work well till now, but will have in mind the warning.

      Among other modules, I've installed Chart::Clicker (not sure now but probably with cpanminus) because found on the web that it is a simple yet powerful tool for plotting graphs etc. It was very surprising to see that it resulted in 102 distributions installed! The examples for that module work very well and graphs are really nice but I would have a question: ok, for a desktop computer the number of these modules is maybe not important but for the server, is it recommended to have just that so demanding module or work with some others?

      At the and, 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?

        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,
        -- Hauke D

        Hi predrag,

        Chart::Clicker is one of those distributions that has *lots* of dependencies, mostly because it uses the Moose object management system. The next time you install a new module that also requires those same dependencies, Perl will see that you already have them and they won't be installed again.

        There should be no issue with space on your server or your home machine.

        A long time ago when computers were not so powerful, there was concern about loading too many modules (whether directly or as dependencies) because your script could be slow to compile. But unless you are in a very specialized situation this should not be a concern either.

        Hope this helps!


        The way forward always starts with a minimal test.
Re^10: Begginer's question: If loops one after the other. Is that code correct?
by predrag (Scribe) on Jan 14, 2017 at 17:31 UTC

    I've just tried your code for my Cyrillic domain name and ACE string I've already got, works perfectly

      Looked at the web and found a website where is stated Lingua::Translit credits are also given to "Perl community" and among others: Thanks to Dusan Vuckovic for contributing the "ISO/R 9" transliteration table

      It is Serbian name and family name, so it seems ISO/R 9 is what should be used for Serbian. I've seen ISO 9 is also reversible.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-19 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found