in reply to Installing CPAN Modules within BEGIN of PERL Script

I'm not sure that this approach would work as you anticipate: installation of modules might require advanced privileges. It also seems clumsy to me to try to do this in this way. Instead, I am reminded of the simple REQUIREMENTS.TXT strategy that is used with Python. Perhaps you could write a script that scans your Perl source-code looking for use statements and extracting the module names. Then, manually sort and de-dupe the list and winnow out the builtins. Now, another simple script could read that file and attempt to install all of the modules therein listed. This is done one time at installation time ... by hand. The essential idea is very simple and it works quite well.
  • Comment on Re: Installing CPAN Modules within BEGIN of PERL Script

Replies are listed 'Best First'.
Re^2: Installing CPAN Modules within BEGIN of PERL Script
by marto (Cardinal) on Aug 19, 2021 at 15:23 UTC

    "Then, manually sort and de-dupe the list and winnow out the builtins"

    This isn't bullet proof. Some distros ship something called perl, without all of the perl core. If the app wasn't going to be published on cpan, hosting it somewhere and providing a cpanfile would provide a dependable route forward.