Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Autovivification with require

by perlfan (Vicar)
on Nov 20, 2020 at 19:48 UTC ( [id://11123924]=note: print w/replies, xml ) Need Help??


in reply to Autovivification with require

Is there a reason you can't convert incl/common.pl to a module (lib/Common.pm)? Using the modulino approach, all but the most stubburn old school .pl "includes" can be made easily accessible as a library and via use. Not saying there are not good cases for require, there most certainly are. If you want to convert common.pl to a module, I'm happy to address any questions in a different thread.

Replies are listed 'Best First'.
Re^2: Autovivification with require
by Bod (Parson) on Nov 20, 2020 at 21:53 UTC

    One include file that most of my scripts use is require "incl/html.pl"; in various forms. Because the vast majority of what I write is web code, this include has subroutines to supply common parts of the web page: header, footer, Javascript routines, etc. So it is really nothing more than a collection of subroutines. Others do common stuff like connect to the database schema(s) and provide logging functionality, etc.

    I usually create two copies of each website depending how complex it is going to be functionally - prod and test. They have identical code except for a incl/variables.pl file which has variables containing database credentials and environment settings like whether or not to send out automated emails.

    So converting them to modules should not be too complex WRT the content. But there are a number of *.pl include files some of which then require another.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-24 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found