How do I deliver (distribute) a Perl application? - windows

I wrote a program in Perl, and now I want to send it to buddy. I don't want him having any kind of bother with launching it.
How do I make some package which he can just click and have all things ready to launch?
PS. I can ask him to download ActivePerl and install it beforehand.
PPS. I don't need to hide .pl sources from him. I need though automatic download and install of all required CPAN modules.
Also, what if in future I will need to scale it for production delivery? Meaning, it will be not a buddy on the receiving side, but Mr. Client?

I have used pp with great success. It can package a Perl interpreter and used modules all together into an executable file.
Then again there is always B::C which provides a perlcc utility, but I haven't had as much luck with that.

For easy distribution to windows clients, its hard to beat PerlApp, Par::Packer (aka pp), or Cava Packager.

Although I like Joel's suggestion best I'd want to point out another solution for you. As it seems you're targeting Windows you could also use the portable version of Strawberry Perl. Install the modules you need, add your script/application to it, setup a simple batch script to launch it with the portable environment and you're set.
The biggest downside compared to the pp (PAR::Packer) solution is that the size of your application will be rather big as pp only includes that what is necessary.

You might be looking for IndigoStar's perl2exe:
Perl2Exe is a command line program for converting Perl scripts to executable files. This allows you to create stand alone programs in Perl that do not require the Perl interpreter. You can ship the executable files without having to ship your Perl source code. Perl2Exe can generate executables for Windows and Unix target hosts.
Of course, the easiest way would be if your clients could run perl.

Yoy may wish to try Cava Packager. It can produce executables from Perl code on Windows, Linux and Mac OS X. It takes an alternative approach to PerlApp, pp and perl2exe. You should probably try them all and decide which you like best.
Note: As indicated by my name, I am affiliated with Cava Packager.

Par::Packer will do the job for you, without any fuss and is completely free. As long as you have installed the correct dependencies, you simply (on a windows machine) open a command prompt, CD into the directory where your perl source (e.g. 'samplefile.pl') resides and type: pp -o sampleprogram.exe samplefile.pl. After a minute or so, 'samplefile.exe' is compiled, and you can send it to your friend to run
Perl2Exe is a proprietary solution, and although it is good, is not free
Good luck!

Related

How do I write a cross platform installer script?

Instead of having a different download of a program for Windows and Linux, would it be possible to make the download be a cross-platform script/executable that can download the correct installer from an FTP server and start that? What language should I write it in? The only one I can think of would be Java, but I don't want to take the time to learn it. I can't write it in Python or BASH, because most Windows machines don't have these installed. How should I do this?
Cross-platform executable(like an exe or a.out or ELF) is out of question. An executable is never cross-platform when Windows is involved. The scripting languages(or JIT compiled) have to be brought in for this purpose. We are in a CHICKEN-AND-EGG paradox. You may have to detect the OS the downloader is using, using a Javascript script in your website page and decide on what is to be done next etc...
Although not exactly what you are looking for, below are some pointers.
The best tool I know of, for multi-platform installers, is Flexera Software's InstallAnywhere. That might be a bit costly. For free options I would look into options like:
PERL
PYTHON (but this is out of question as per your post, but look at the end of my post for more options for Python)
Although writing the installer in any of the above languages might mean a lot more work, they provide you unmatched flexibility and complete control.
Perl requires that you install Perl interpreter and modules on Windows. But this also seems to be out of question for you. So you may avoid the headache by looking into:
PAR
pp
For Python go through:
py2exe
pyinstaller

I need a way to run Haskell code without any install on a Mac

I enjoy developing in Haskell, but am presently confronted with a challenge. At my place of education, I don't have administrative rights on my account. I want to debug/test while there. I need a way to run Haskell code without installing haskell-platform or ghci or anything else requiring of an administrative level of privilege. For instance, a web site which will run haskell code (abeit limited to not include file access of course) or a java utility (or standalone .app, though java is preferred due to the nature of the "parental controls"), or something else I haven't thought of. Source or compiled Java, Flash, and source code in Ruby or Python are preferred to native code. This is on Mac OS X 10.6, for reference.
You can install GHC without admin privileges, but you'll have to build from source. Check out the Building on MacOS X for more details.
Essentially, like any other open-source project, you can compile code and install it, generally, anywhere on your filesystem like into a folder in your home folder (I often use the ~/.local folder for that purpose).
As the linked page mentions, you can also use MacPorts and install it to any place you can write to. Once MacPorts is installed you can install GHC.
EDIT
As pointed out by Carl in the comments below, you don't need to build from source. Just grab the binary tarball from http://www.haskell.org/ghc/download_ghc_7_4_1#binaries.
In addition to all the other ideas, several companies will rent you virtual (cloud) linux servers for a few cents an hour. You have root on those and can install whatever you want, then freeze the image until you need it again.
Normally this might not be advantageous over a local solution if you can make one work, but a possible extra benefit would be that your work can stay on a single "computer" which you could access while sitting in front of any variety of modern PC that might be available to you on a given day.
An alternative not only for Haskell is http://ideone.com/
For the website option, TryHaskell will hardly cut it, it's way to limited.
codepad, OTOH, is more liberal, and should be of more use.
But honestly the bindist option is the best one, clearly!
If you truly can't install anything, then there's
http://tryhaskell.org/ -- like GHCi, but you can't load modules, which means not only that you can't use many standard functions (say, the functions in Data.List), but also that you can't use certain language features (like user-defined algebraic data types).
I also remember a hpaste-style site which executes its code -- and allows you to have private pastes -- but I can't remember it at the moment. Edit: I was thinking of http://codepad.org/ -- thanks #Mog
Try http://hiji.tinyrocket.se/ It is a haskell interpreter written using javascript.
http://ghc.io/ GHC.IO is a version of the Haskell interactive interpreter, ghci, that runs online in a web browser.
You just need to install homebrew, which you can do without root rights if you do so in your home directory. You can then brew install cabal-install
which will automatically install cabal and ghc, or brew install stack to install stack.
There is a web-based interpreter for Haskell at http://tryhaskell.org/. However, it may not provide enough functionality for your requirements.

Learning Perl, but how do I get 5.14 on Windows?

So I ordered Learning Perl 6th edition and I know it's using 5.14, but Strawberry Perl is only at 5.12, so what are my options? Is 5.12 fine for it or will there be problems with what's being taught?
Is my only option using Linux? If so distro suggestions would be good along with instructions or a link to instructions on updating perl in said distro (or in general). I'm relatively new to Linux, only ever having installed Ubuntu a few times and never really stuck with it. The perfect solution would be a distro that's good for installing on another PC in my house so I can just remote desktop (or equivalent, even SSH, though GUIs are nice) into since I have an older PC that I want to put a new hard drive in and mess around with. (Pentium 4 with a bit less than a gig of RAM so not awful)
Hopefully this question is considered more constructive than my last two and I look forward to your responses.
Edit: Also any resources for a Linux noob would be a great help if possible and if it's the best option.
I haven't actually seen Learning Perl 6th edition, but I would be very surprised if you had difficulty working through it with Perl 5.12. Perl 5.14 is still too new for most people to be writing code that requires it. The book may mention some features that you can't take advantage of in 5.12, but it should still explain how to accomplish things using only 5.12 features.
I would recommend just using the current Strawberry Perl and not worrying about the version number.
Update: As Mike pointed out, here's the opening paragraph of the Preface:
Welcome to the sixth edition of Learning Perl, updated for Perl 5.14 and its latest features. This book is still good even if you are still using Perl 5.8 (although, it's been a long time since it was released; have you thought about upgrading?).
So that confirms you'll have no problem trying to use 5.12 with the 6th edition.
Use ActivePerl
It is a very good product, it is free, and it has a reliable (for the most part) PPM (Perl Package Manager). I use it and have no troubles usually. It is a binary distribution just like Strawberry Perl, but you use PPM to get modules instead of CPAN.pm.
Note: If you are getting Perl 5.14 Just because of the book, don't. I got that book (I am also a beginner) and used 5.12.4. You get mostly all of the features (except for a few ;-)
I moved from Windows and PHP to Linux and Perl a while ago, and haven't looked back - but I don't want to start an OS or programming language war here. My desktop is running Ubuntu, but you could stick with Windows (I have Windows available in a VirtualBox VM for those times when I need it).
You can download the Ubuntu Server ISO and attach it as a CD/DVD image via the Virtual Media Manager. You can then set up as many Ubuntu VMs as you like. I use very basic setting for mine:
RAM: 512MB
Hard Disk: 8GB dynamic
Network Adapter: Bridged
I have a few images configured. One is setup with Nginx + Catalyst, one with Bricolage CMS and Apache, and a few other variations (including a PHP one). The great thing with VMs is that you can create snapshots, duplicate images, experiment, and blow things away and restart if you mess things up.
How you choose to setup your development environment is down to personal choice. I use SSHMenu to open four SSH connections to my development server - this also places the terminals at predefined positions on my screen.
I use one terminal to run code, access the debugger, etc. I use another for connecting the DBMS client (PostgreSQL / MySQL). I use the other two for editing code and unit tests. I use Vim in the terminal as my editor. I was going to try Emacs too, but never got round to it.
I use git as my version control system, with bare repositories on a separate file server. I did start with Mercurial, but it appears as though much of the Perl world is using git, so I switched.
I have configured the GNOME terminal to use the beautiful Solarized colour scheme (you can find a handy script for that here).
As for the Perl version: I don't know. I agree with other comments about using a standard package rather than trying to build your own - especially if you are a Linux newbie. I've just looked on the O'Reilly preview page, and in the Preface, it says "this book is good even if you are still using Perl 5.8" - so you should be okay with an earlier version. You also need to be aware that if you are planning on doing web development in Perl, you may be limited to older versions of Perl by your chosen hosting provider.
A few more thoughts:
Programming Perl, despite its age, is still a great resource. One you've completed Learning Perl, and perhaps Intermediate Perl, it's well worth reading. The section on Pattern Matching (regular expressions) is fantastic.
Modern Perl is a really good read. It's well written, concise, and full of really useful tips.
cpanm is a great alternative to the standard CPAN application.
local::lib is very useful. I use it to create a per-application set of CPAN modules. This means that I can simply copy the entire directory structure from my development server to the application server, without having to worry about conflicts with other applications that might be using different versions of the same modules. This is probably not relevant to you at the moment, but when you've learned more and start using lots of CPAN modules, it can be really handy.
A quick local::lib example:
mkdir -p ~/myapp/extlib
cpanm --prompt -L ~/myapp/extlib CPAN::Module1 CPAN::Module2 ...
eval $(perl -Mlocal::lib=~/myapp/extlib/)
In ~/myapp/scripts/myscript.pl:
use FindBin;
use local::lib "$FindBin::Bin/../extlib";
You could
Install Windows and then run Ubuntu inside a VM on your Windows machine. You can start it up, ssh to it and then mess around with it.
Use ActivePerl.
Simply use ActivePerl - you can download 5.14 or 5.12 and it's as good as Strawberry, even with the complete CPAN toolchain, nowadays. The only limiting factor is the license, it's absolutely free to use but you can't bundle it in any of your apps without getting an OEM license. So for 99% of the cases this is a good distribution.
StrawberryPerl is also suitable, but they usually have a slightly longer delay between the release of a Perl version and the availability of an updated StrawberryPerl version.
I have a fully updated Ubuntu 11.04; it has Perl 5.10.1. I don't know how up to date other Linux distributions are. Cygwin also has 5.10.1.
You could always build from source.
Well, you can either use Active Perl, or use a GNU/Linux distro and get the latest Perl from it's repos. GNU/Linux is not Windows, it is open-source and you can install it on as many PCs as you want it. You could try Ubuntu or it's builds for an easy-to-use system.
Most of Learning Perl doesn't depend on Perl 5.14 features, and those that do are clearly marked. In most cases, I try to show a non-v5.14 way to do the same thing. You'll miss out on some nice v5.14 features, but you won't be stuck without them. And, for what it is worth, the new Programming Perl, due very soon, covers up to v5.16. Don't buy the old version if you don't have it yet.
Many people have already suggested very good options for various Perls, so I won't repeat those. My advice to students is always to learn on the Perl version and operating system you want to deploy to.
You don't have to stick to Windows. You can get a virtual machine of just about any operating system you like. VMWare and Oracle VirtualBox have free players and many places offer pre-configured virtual machines. From there, you can install any Perl version that you like. It's also incredibly cheap and easy to have multi-boot systems (although a VM doesn't prevent you from using both at the same time).
On Windows, you can also install cygwin, then install any Perl that you like.
Also, there is a preview release for Strawberry Perl 5.14.

Scripting language that can produce a small, independent, Windows EXE?

I'd like to do some light data processing - a little binary data manipulation followed by conversion to text serialization. The result is written to a file, and processed by an external program (run by my program). The data processing is more than I'd care to consider doing in batch files.
I'd prefer to use a scripting language, but not have to install the language first. The target computers are mostly older Windows boxes, which are disconnected from the network (no updates, such as PowerShell)
I'm not familiar with the various language's tools for creating EXE files. Which ones have solutions that work well and don't produce huge files? (i.e., whole interpreter package plus my script.)
For my money (its free) AutoIt 3 is exactly what your looking for. AutoIt produces relatively (250k is the standard overhead) small stand alone exes. It has a full perl like regex engine so your light data processing should be a breeze (I've written some pretty heavy data processing scripts in it myself). When downloading autoit be sure to get the full version including Scite this makes compile to exe a one click operation.
I know I might get flamed for this, but VB 6 is a viable option. Since XP SP2 (I think, possibly earlier), Windows has come with its runtimes installed. Not sure about vista.
Theres also the Windows Scripting Host that uses VBScript and JScript.
http://en.wikipedia.org/wiki/Windows_Script_Host
Lua is an excellent choice for that kind of stuff. You can integrate it in your executable or use the standalone Lua interpreter to run your scripts.
While waiting for answers I ran across Shoes, which can make Ruby .exe (I'm most familiar with Ruby) I got it mostly working, although the size of 2.4MB was a bit larger than I'd like. However, I found that it would crash when changing application focus.
I switched to a 'regular' terminal script, and found rubyscript2exe, which, after working around a problem with rubygems, seems to work, and creates a ~700kb file.
I did rather like some of the options presented, but it's not worth redeveloping at this point.
Python with py2exe. Depends on what you mean by small though.
Would using PowerShell script be something you've considered. The data processing might be richer there.
Why not knock up a .NET application? There are free editions of the IDE, and the Framework comes with Windows as a standard component (which also includes a C# compiler, as it happens.)

What is the quickest path to writing a lightweight GUI program on Windows?

I want a small (< 30MB) standalone Windows executable (a single file) that creates a window which asks the user for the location of a directory and then launches a different program in that directory.
This executable has to run on XP, Vista, Server 2003, and Server 2008 versions of Windows in 32-bits and 64 bits on x86-64 architecture as well as Itanium chips.
It would be spectacular if we only had to build it once in order to run it on all these platforms, but that is not a requirement. This is for a proprietary system, so GPL code is off-limits.
What is the fastest way to put this together?
These are some things I'm looking into, so if you have info about their viability, I'm all about it:
Perl/Tk using perl2exe to get the binary.
Ruby with wxruby
Learn MFC programming and do it the right way like everybody else.
What about a WSH script? It won't be an exe, right, but to ask for a folder I don't see the need for an exe file, much less a 30Mb one...
A 1Kb script, save it as whatever name you like with vbs extension and run it. This, in case it's not clear, asks you for a folder name and then runs calc.exe from the system32 subdirectory. You can of course do a lot better than this in 2 or 4 Kb.
Set WshShell = WScript.CreateObject("WScript.Shell")
win = InputBox("Please type your Windows folder location.")
If Right(win,1) <> "\" Then
win = win & "\"
End If
WshShell.Run win & "system32\calc.exe"
To add a Folder Browser dialog instead of an InputBox, check this out.
Clear benefits are:
Simplicity (well, VB is ugly, but you can use JScript if you prefer), no need to compile it!
Compatibility, works on every windows machine I have available (from 98 onwards)
I'd use .NET and WinForms. The idea of scripted solution is appealing, but in practice I often find you end up jumping through hoops to do anything beyond the basic case and still don't have the flexibility to do everything you want.
Quickest way on Windows for a lightweight and fast GUI? One word.. Delphi! It lacks the 64 bit support for now but then FreePascal would come to the rescue.
Having a small stand-alone application and developing it quickly are, I'm sorry to say, usually conflicting requirements.
To be honest, given how incredibly simple the application is, I would write it in C with direct Win32 calls: one call to SHBrowseForFolder() to get the directory, and one to ShellExecuteEx() to run the program. Even MFC is far too heavy-weight for such a modest application. Set the C runtime to be statically linked and you should be able to keep the size of the stand-alone executable to less than 100k. A decent Windows C coder should be able to knock that up in less than an hour, assuming you have one to hand.
Python with either wxWidgets or Tkinter should be able to do this with almost no effort at all. Runs on everything, and py2exe will get you a standalone executable.
Tcl/tk is one solution. You can have a single file executable (including custom images, dlls, etc) using something called a "starpack" -- a virtual filesystem that is both tcl interpreter and application code. I think it would weigh in at maybe a couple megabytes.
From your specifications it would take me personally maybe 15 minutes to get a first working version.
Tcl/Tk has a BSD license.
For all of its flaws, Visual Basic has historically been great for super-simple apps like this.
I agree with the Tcl/Tk answer above. For more information about the starpack that he refers to, see: http://www.equi4.com/tclkit/ it's a Tcl/Tk interpreter available for various OS's all in about 1MB. In the past there apparently has been concerned about the look and feel of Tcl/Tk UI's, but this has been addressed by a new framework named "Tile" that supports the native look and feel of the user's OS.
For a quick and dirty GUI program like you said, you can use an AutoIt script. You can even compile to an exe.
For an GUI example of AutoIt, you can check my stdout redirect script in a previous answer here
wxWidgets; it's cross platform, free, open source and easy to learn
You could do this in MFC and have an executable in under 100k. In general, if you want to keep the size of your executables down, you can use UPX to perform exe compression. If you want an example, take a look at uTorrent. It's a full featured BitTorrent app in less than 300k of executable.
I use HTA (HTML Application) for quick-and-dirty form & script applications. See Microsoft's HTA Developers Center for details and examples. This basically uses HTML for the form, and any HTML-accessible scripting language for the script. Normal browser security is bypassed so that you can get at almost all OS internals. The above site also contains links to several tools that nearly automate the scripting part for you.
PyQt works really well for this. Binaries for Windows here:
http://www.riverbankcomputing.co.uk/software/pyqt/download
A good book here:
http://www.amazon.com/Programming-Python-Prentice-Software-Development/dp/0132354187/ref=sr_1_1?ie=UTF8&qid=1295369454&sr=8-1
And you can freeze these using various methods if you need exe(s).
Similar to what Vinko Vrsalovic said, you can use a HTA application. It is as easy as building a webpage with windows scripting host functionality. I have built a few utilities with jscript and it is really easy and quick
http://msdn.microsoft.com/en-us/library/ms536496(VS.85).aspx
These responses are unbelievable.
Visual Studio Forms editor lets you draw out WinForms and autogenerates the boilerplate GUI code (which is a pain in the ass at best for most other languages and toolkits). Then you can use C# or any other .NET language. .NET has stock widgets for file pickers. I could write that script in 20 minutes and it will run on every one of your target platforms for free. Draw out the GUI, drag-n-drop a file picker, fill out maybe two hooks to do the "launch a different file than they wanted" thing, done.
I suggest Autohotkey (AHK) or Autoit. Both support win95+ (with caveats for certain functions). They can be compiled into small .exe without external dependency (besides native DLL's).
Pros:
small size
easy to write code
useful for simple - complex operations
can create GUI easily
Cons:
learning curve (as syntax is unusual)
30MB is pretty huge!
Qt (C++) may be the best choice. It is portable, quick to develop and relatively fast to run. With UPX (Ultimate Packer for eXecutables) your program will be 10M+.
Qt (Python) is OK too, but will be slower.
If you want it less than 1M and/or you want it quick, you can write it in C with win32 api, or use Delphi.

Resources