ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm new to the world of Perl so may have gone about this in the wrong way (my background is mainly Java and Bash).
I have a Perl script (gallery.pl) which takes in various arguments (the only mandatory arguments is a directory full of images) and creates an HTML, standards compliant gallery. Seeing how images might be too big, I use the Image::Magick module to do any resizing that is necessary.
If I want to pass this script to a technically minded user to use then I'd just email the script or put it on my site for them to download and then they can sort out any modules they need to install.
However, what about non-technically minded users? How can I distribute my script in such a way that the end user doesn't have to care about missing dependancies?
I've thought about an installation script to install the main script under /opt/local/bin, could I use this installation script to install missing modules? If so, how might I do this?
I've tried looking at things like Module::AutoInstall and ExtUtils::MakeMaker but my interpretation is that these are only for modules, not for scripts.
Sorry to sound so dim about it all, but as I said, it's all rather new to me!
Many thanks,
Ben
Last edited by forquare; 07-27-2010 at 08:34 AM.
Reason: Rectify spelling mistake
I've looked at CPAN, but didn't understand how it could help with my problem other than if I uploaded my script to CPAN. I'm not sure this is the right option for me, certainly not at this time.
I've looked at CPAN, but didn't understand how it could help with my problem other than if I uploaded my script to CPAN. I'm not sure this is the right option for me, certainly not at this time.
Thanks again,
Ben
I think what you're looking for is "pp", or the Perl Packager. Works great for me. It may be available in your repos, or you can grab it from CPAN here:
It essentially 'compiles' a Perl program into an executable. Send it out like you would any other executable, and it'll have everything it needs to run, no tweaking of the environment needed. Works on Linux and Windows, anything that supports Perl.
If you want to distribute the script without compiling it, I'd suggest to NOT automatically install modules because some distributions also package them and the user could very well prefer installing the distribution's package over CPAN...
But you could make your script give better error messages by "require"ing the package in an eval block like this:
Code:
eval {
require Image::Magick;
};
if ($@)
{
print STDERR "Module Image::Magick was not found.\n";
print STDERR "In order to use this script, please install the Image::Magick package for perl.\n";
exit(0);
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.