You really didn't say much about what you're trying to do. You said you
did some stuff and some other stuff didn't happen. It's hard to help
you -- what *exactly* is the problem? (There are plenty of things that
install and run apps on the CPAN. App::Ack comes to mind. It Just
Works, there is nothing special you need to do.)
That said, I always do this:
package MyApp::Script::Whatever;
use Moose;
with 'MooseX::Getopt';
has ...;
sub run { ... }
Then:
#!/usr/bin/env perl
use FindBin qw($Bin);
use lib "$Bin/../lib";
use MyApp::Script::Whatever;
MyApp::Script::Whatever->new_with_options->run;
This is similar to your "parse $0" solution. But of course it won't
work for installed scripts where the library directory isn't in @INC.
> If I put #!perl at the top of display.pl it will have a path to perl
> (though not the one I specified), but it won't have "use lib $HOME/MyApp/lib"
> at the top of the script, so it can't run.
> Furthermore, there's no way for the script to know what was used
> for install_base, so there's no way for the script to know where the data
> file is located.
>
> This must be something people do, right? Currently I hard code paths
> and force the installation to be where I want it, but this seems really
> sub-optimal, doesn't work for having test environments, etc.
> I've been considering parsing $0 at the top of the script, is that
> what other people do?
>
All I can say about this is ... right. You need to put the path where
you install stuff into @INC (via PERL5LIB). See local::lib, for
example. Module::Build (etc.) isn't going to edit your file to
hard-code the install path... I guess you could do that, but I've never
seen anyone do that.
Perhaps you are worrying a problem that doesn't exists?
Regards,
Jonathan Rockway
--
print just => another => perl => hacker => if $,=$"