http://www.perlmonks.org?node_id=1017580

gideondsouza has asked for the wisdom of the Perl Monks concerning the following question:

Update:

So I found what I was looking for, it seemed like sorcery to me but all I was looking for was EXE_FILES inside the Makefile.pl


So I'm hoping to develop a simple little app module. App::MyApp

I looked at module starter and couldn't really find what I was looking for. I just have two questions:

  1. During a cpan/install, How/When do install my perl script app into the the users bash (like when module starter is installed you can now use it in bash). Note the when? I'm wondering whether there is an install event/func that gives me a handle to when the user is installing the module.
  2. Do I also have to take care of marking .pl file as executable or can I install a bash script that runs my perl script? (like module-starter is used as an executable inside bash?)
  • Comment on how do you install a perl app::someapp module in bash

Replies are listed 'Best First'.
Re: how do you install a perl app::someapp module in bash
by kcott (Archbishop) on Feb 07, 2013 at 08:14 UTC

    G'day gideondsouza,

    I don't know how far you delved into Module::Starter, but I believe there's probably enough there to give you an idea of how to proceed.

    At the top of the CPAN documentation, you'll see a link to Module-Starter-1.60. This link will lead to a page with a lot of information about the distribution: makefiles, older versions, CPAN testers feedback and so on.

    Following the link to Makefile.PL, you see:

    ... EXE_FILES => [ 'bin/module-starter' ], ...

    Following the MANIFEST link will show a list of all the files used and their locations. You'll see bin/module-starter which, in turn, is a link to the source code for the module-starter script.

    All CPAN modules have the same sort of setup. If you want to create a new module that has similar features to an existing module, you can follow these and similar links to see how its already been done.

    -- Ken

      I kept looking at the source, never would have thought it was in the Makefile!

      I feel so awesome that this is all it was to make such powerful magic work! Thanks very much! :) I updated my question too.

Re: how do you install a perl app::someapp module in bash
by nagalenoj (Friar) on Feb 07, 2013 at 07:51 UTC

    Hi,

    I hope your first question is about installing your script in linux machine, so you could launch the script from any directory. For this, either you can change the $PATH bash variable in ~/.bashrc file, append it with the directory which your script exists or create a link to your script under any directory which already exists in $PATH.

    export PATH="$PATH:/home/YOU/YOUR_DIRECTORY";

    For your second question to make the script executable, yes, you have to give it executable permission and don't forget to add the shabang inside the script.

      Yes you need to make your perl script executable, or you need to specify the perl interpreter path manually like, #/usr/bin/perl perlprogram.pl

      Ah Thanks, this is what I was looking for. But what event (or WHEN?) do I do this? Is there an install event that will give me a handle to when a module is installing.

      So any ideas about windows? I'm guessing I have to change the PATH variable and there is probably a perl module for it :)

Re: how do you install a perl app::someapp module in bash
by Anonymous Monk on Feb 07, 2013 at 08:00 UTC

      Ohhhh!!! This is awesome!

      EXE_FILES is what I was looking for! Thank you :D