Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Bod

by Bod (Scribe)
on Nov 15, 2020 at 00:48 UTC ( #11123653=user: print w/replies, xml ) Need Help??

Long time amateur coder since growing up with a ZX Spectrum and BBC Micro...

Introduced to Perl in the early 1990's which quickly became the language of choice. Built many websites and backend applications using Perl including the sites for my property business:
Lets Delight - company site
Lets Stay - booking site
Also a few simple TK based desktop apps to speed things up.

Guilty of only learning what I need to get the job done - a recipe for propagating bad practice and difficult to maintain code...difficult for me so good luck to anyone else!

Now (Nov 2020) decided to improve my coding skills although I'm not really sure what "improve" means in this context. It seems Perl and best practice have come along way since I last checked in and my programming is approach is stuck in the last decade.

Onwards and upwards...


Find me on LinkedIn


Posts by Bod
CPAN PREFIX or INSTALL_BASE in Seekers of Perl Wisdom
3 direct replies — Read more / Contribute
by Bod
on Nov 24, 2020 at 08:11

    Thanks to bliako in Re^3: To Framework or not to Framework and others in the same threadnode, I am trying to install a module using SSH to shared hosting as this has been disabled in cPanel. I am using PuTTY to connect. The module I'm trying to install as a test is Image::Info because it is small and useful so makes a good test.

    The files are fetched OK and I can see them in the /home/shoples1/.cpan/build/ directory but install within CPAN finishes up with this error:

    Configuring S/SR/SREZIC/Image-Info-1.42.tar.gz with Makefile.PL Checking if your kit is complete... Looks good Only one of PREFIX or INSTALL_BASE can be given. Not both. No 'Makefile' created SREZIC/Image-Info-1.42.tar.gz /usr/bin/perl Makefile.PL PREFIX=/home/shoples1/perl/usr -- NOT OK Failed during this command: SREZIC/Image-Info-1.42.tar.gz : writemakefile NO -- No + 'Makefile' created
    From what I can tell, CPAN is trying to use two different and incompatible configuration methods but I have no idea how to tell it to only use one. From this information I have found conf makepl_arg but CPAN says:
    Unknown shell command 'conf'.

To Framework or not to Framework in Seekers of Perl Wisdom
5 direct replies — Read more / Contribute
by Bod
on Nov 23, 2020 at 12:54

    Despite regularly visiting The Monastery in the past, especially when the Great God Google has pointed me this way, in the last week since I created an account I have learnt a great deal...one such thing is the existence of frameworks for building websites. Until yesterday this was something that sat on the 'one day' pile - but now I have to build a new website so I am seeking help in deciding whether to use a framework or whether to do it in a similar way to I've previously done it but with use strict; firmly in every script!

    My partner has been dabbling with artwork for some months and wants somewhere to showcase her work and to be able to take commissions and make sales of prints.

    Here is an example if you are interested

    So...the website will only be maintained by me thus ensuring that others can maintain the code is not a consideration. Functionally it is not too complex with a few database tables and a very basic CMS so Joolz (my partner) can upload images of artwork and change their descriptions, etc. There will be some image manipulation (probably using GD::Image) to resize thumbnails so they cannot be usefully copied and to add a watermark to larger images but that would be the same however the rest of the site is implememnted (wouldn't it?)

    Previous websites I have created have a standard library I have written to deal with form processing, image uploads, logging etc. They then have site specific subroutines for the boilerplate code common to multiple pages and to deal with database connections. All of this standard code is in *.pl files that are brought in with a require statement.

    I would love your input of whether it would be beneficial to go through the (steep?) learning curve of implementing this new site with a framework or whether it would be preferable to use the boilerplate methodology that I am used to albeit using *.pm modules for the common parts and bringing them in with a use statement. I feel that I do not know enough about the advantages and potential pitfalls of adopting a framework to be able to make a decision.

    I'm not asking for you to try and make a decision for me...but please...give me some pointers and shine a light into the dark corners where frameworks and other design considerations tend to lurk.

Autovivification with require in Seekers of Perl Wisdom
2 direct replies — Read more / Contribute
by Bod
on Nov 19, 2020 at 17:53

    Esteemed Monks

    Thanks to the The Monastery, I today found out about Perl::Critic so thought I would throw a recently written, small (600 lines) Perl script at it just for fun...so I used the website tool knowing that it would complain that scriptures were off.

    It has highlighted 12 issues amongst them:
    "require" statement with library name as string at line 10, column 1. Use a bareword instead.

    I've looked this up and understand what it is suggesting I do

    require "incl/common.pl"; # What I've got require incl::common.pl; # What Critic suggests I have

    I've consulted the documentation for require and I understand the portability advantage of the slash being the other way on some systems. As my code will never be run in another environment, I don't see the advantage of backdating the code for this reason but going forward, that makes sense.

    But then we get to autovivification...
    Off to the Wikipedia Article as this is a term I have heard but always shied away from...time to properly understand. I think I now sort of understand but certainly not well enough to articulate it to myself let alone explain it to anyone else.

    I do understand that the syntax I have used for require will not autovivify whereas the version suggested by Critic will. What I certainly do not understand is how this makes any practical difference in any way. Whether the magic happens at compile time or run time surely doesn't matter here as the code only runs once for each executed instance; which equates to someone (or some machine) requesting a page from the webserver. I totally get that in many cases there are major differences between compile and run time - but here in a require statement?

    Does it actually matter in practical terms or is autovivification in this example just a theoretical matter here?

Backdating strict in Seekers of Perl Wisdom
8 direct replies — Read more / Contribute
by Bod
on Nov 17, 2020 at 14:51

    Over in Re^2: Newline's creep in, while using Tie::File I asked what I though was simple question...
    should use strict; always be used or are there circumstances when it makes sense not to use this pragma?

    As is often the case, I didn't realise where this simple question would lead. Several clever Monks have shown me the wisdom of using this simple but powerful line in every script going forward. But that is going forward...

    I have many, many lines of production code within lots and lots of scripts and none of them use strict; To be clear, all the code works well in that it does everything it is supposed to do consistently and within an acceptable time. Some of it is evolving, some is largely static and I do not see it being developed further.

    So my question is, given that I see the value of use strict; going forward, what might I do with existing, working code. Is there any benefit to going back over working code, breaking it and having to repair it again to include this pragma?

    I do have test environments so I would not have to break the code whilst it is in production!

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2020-11-26 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?