Shrinkwrap Software
with Perl, PAR and SOAP

Chris Dolan

MediaLandscape Software

cdolan@cpan.org

Properties of shrinkwrap

Contrast traditional Perl software

Can't locate Foo.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.6
/usr/lib/perl5/site_perl
/usr/lib/perl5/5.8.6 ...

A solution in two parts

Part I: PAR

PAR to the rescue

What is PAR? Perl Archive Toolkit!

 
 
 
 

PAR example

% pp -o MyProgram MyProgram.pl
% ./MyProgram

PAR's pp program finds all of the dependencies in your program via Module::ScanDeps then zips those files into an archive and prepends an executable header (including libperl).

For Windows, add the --gui flag if you want to avoid the console window.

How PAR works

 
 
 
 

At runtime, the PAR executable unzips itself into a temp directory and loads the libperl dynamic library. The @INC is modified to look in the temp directory first. PAR then finds the main .pl file and runs it.

Because libperl is embedded, this works even on computers where Perl is not installed.

Advanced PAR Usage

Add extra libraries:
% pp -l /sw/lib/libjpeg.62.dylib -o jpegmunger jpegmunger.pl

Exclude runtime features:
% pp -X Foo::Plugin::Advanced -o foo_lite foo.pl

Exclude unneeded functionality:
% pp -X DBD::mysql -o sqllite_browser sqllite_browser.pl

Disadvantages of PAR

sub hints_for_PAR {
   require Encode::Unicode;
   require LWP::Protocol::https;
   require URI::https;
}

Don't worry, Module::ScanDeps is improving

Part II: SOAP

The problem: GUI?

Perl does have GUI toolkits: Tk, Wx, Qt, GTK, CamelBones. But most GUIs are developed in other languages. Why?

A solution: modularize!

SOAP cleans your interfaces

What is SOAP? Simple Object Access Protocol

Client – Server

SOAP

If you can write a CGI service, you can write a SOAP service.

When your GUI application launches, it attempts to contact the server. If the connection fails, it forks and execs the server.

The GUI is stateful, the engine is stateless (or less stateful), just like in the web paradigm.

An example

MediaLandscape Converter

Solution: Flash GUI, Perl server, C++ engine

Nuts & Bolts

How do you implement the solution?

Another example

MediaLandscape Presenter

Solution: Cocoa GUI, 6 PAR exes, Perl glue

More advantages of SOAP

Disadvantages of SOAP

Summary

Shrinkwrap software requires technologies that simplify yet beautify the experience for the user. PAR and SOAP help Perl to accomplish that by: