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

I'll second bod's thoughts in 11157199.

Some additional thoughts:

If you want to use your script as both a script and a module then have a look at the modulino idea.

Your MyFindBin code might be simplified by using FindBin, possibly in tandem with lib. There is also rlib for relative file structures. Maybe your code uses these approaches already.

  • 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:53 UTC

    Thanks, yeah, I was looking at the FindBin module. But I'm just going to dump all the scripts in the same directory and there's a change, albeit small, this location can change. So I wanted that to be dynamic, so I threw this code into my own module:

    our $MyBin; BEGIN { my $file = __FILE__; # get the path to the directory of this file using File::Basename my $package = __PACKAGE__; $package =~ s/::/\//g; # chop off the package name from the end of the file path $file =~ s/$package\.pm//; $MyBin = $file . 'bin'; }
    But maybe I'm not understanding FindBin

    $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