Bod has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Autovivification with require
by Fletch (Bishop) on Nov 19, 2020 at 23:11 UTC | |
by Bod (Parson) on Nov 20, 2020 at 15:39 UTC | |
by Fletch (Bishop) on Nov 20, 2020 at 16:34 UTC | |
by choroba (Cardinal) on Nov 20, 2020 at 22:34 UTC | |
by Bod (Parson) on Nov 20, 2020 at 22:47 UTC | |
by eyepopslikeamosquito (Archbishop) on Nov 20, 2020 at 23:41 UTC | |
| |
by bliako (Abbot) on Nov 21, 2020 at 13:06 UTC | |
by Bod (Parson) on Nov 21, 2020 at 14:46 UTC | |
by Anonymous Monk on Nov 20, 2020 at 14:47 UTC | |
|
Re: Autovivification with require
by perlfan (Parson) on Nov 20, 2020 at 19:48 UTC | |
by Bod (Parson) on Nov 20, 2020 at 21:53 UTC |