in reply to Looking for suggestions for accessing/running scripts needed by a local Perl library

What do others think of this approach?

Two things immediately strike me...

  1. Normally modules are used by scripts. Not the other way around. So my initial design choice would be to encapsulate the functionality of your scripts into their own modules. If more than one script needs VCF export functionality, that should be in a module. which can then be used by other modules and/or by scripts.
  2. Using system to run Perl scripts from within Perl is bad practice - I don't understand the nuances of what problems it causes (hopefully others will educate us both), but I do know it's not something you should do. With some thought about design, it should never be necessary either.
  • Comment on Re: Looking for suggestions for accessing/running scripts needed by a local Perl library
  • Download Code

Replies are listed 'Best First'.
Re^2: Looking for suggestions for accessing/running scripts needed by a local Perl library
by nysus (Parson) on Jan 24, 2024 at 03:48 UTC

    WRT #1, my modules sometimes need to execute scripts like the export functionality I mentioned. There is no way I could find to dump out Contacts without a GUI other than using an applescript.

    WRT #2, I think it's mostly a security issue and it's easy to inject bad stuff into poor written command run by system. But since my modules are just for my own use on my own, local machine, I'm not sweating any security issues. I've got bigger problem if someone has hacked my machine and can pass nasty things to my perl scripts.

    $PM = "Perl Monk's";
    $MC = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar Parson";
    $nysus = $PM . ' ' . $MC;
    Click here if you love Perl Monks

      If I wanted to do it quickly because the details didn't matter much, I would just take the non-perl scripts and give them a distinctive name (unlikely to interfere with regular commandline use) and put them in ~/bin

      If I wanted a clean solution that was CPAN-looking (even if not going there yet) I would build a module with Dist::Zilla and put the non-perl scripts in ./share and then access them with File::ShareDir.

      Any external script that *was* perl, I would refactor into a module and put it in my module path. Well.. unless it was massive and complex and written by someone else, then maybe I would just shell out to it. But I would at least *intend* to refactor it into a module some day.