LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-27-2010, 08:31 AM   #1
forquare
LQ Newbie
 
Registered: Jul 2010
Distribution: OpenSolaris, OS X
Posts: 6

Rep: Reputation: 0
Distributing a perl script


Hi all,

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
 
Old 07-27-2010, 08:45 AM   #2
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: Debian 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,766

Rep: Reputation: Disabled
www.cpan.org should be the right place for this
 
0 members found this post helpful.
Old 07-27-2010, 10:57 AM   #3
forquare
LQ Newbie
 
Registered: Jul 2010
Distribution: OpenSolaris, OS X
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks for your response amani,

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
 
Old 07-27-2010, 02:10 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,617

Rep: Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963Reputation: 7963
Quote:
Originally Posted by forquare View Post
Thanks for your response amani,

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:

http://search.cpan.org/~mdootson/Wx-Perl-Packager-0.26/

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.
 
1 members found this post helpful.
Old 07-27-2010, 02:44 PM   #5
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
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);
}
 
1 members found this post helpful.
  


Reply

Tags
cpan, distributing, modules, perl



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with perl modules declaration and perl/cgi script shifter Programming 9 02-24-2010 09:09 AM
call perl script through another perl script with arguments nanda22 Linux - Newbie 21 07-21-2009 12:18 AM
NEED HELP IN comment lines PERL Perl script adam_blackice Programming 17 11-07-2007 08:01 AM
Converting a Windows Perl script to a Linux Perl script. rubbercash Programming 2 07-19-2004 10:22 AM
Including methods from a perl script into another perl script gene_gEnie Programming 3 01-31-2002 05:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration