NAME

PlugIn - Create and Access TAR.GZ files containing executible Perl code for dynamic execution

SYNOPSIS

  use PlugIn;
  my $fileswritten = Write('prog.dat', 'prog1.pl', 'prog2.pl');
  print "$fileswritten files written...\n";
  my %filesread = Read('prog.dat', 1);
  Open('prog.dat', 1);
  OpenEval('prog.dat');

ABSTRACT

PlugIn is a convienient way to store 'required' perl scripts in a single accessible file. It is also a way to obscure source code from prying eyes by adding your own encryption or obscurement routines.

Since 'required' modules are accessed at run-time, PlugIn can also be used to dynamically configure perl scripts that have been compiled using one of the commercial Perl compilers. This gives you the ability to create a free-standing EXE, but keep it dynamically configurable through the use of a plug-in data file without the need for re-compilation and distribution!

The current version of PlugIn is available at:

  http://home.earthlink.net/~bsturner/perl/index.html

CREDITS

Thanks go to Indy Singh of WWW.DEMOBUILDER.COM for providing the 'eval' source to obscure run-time compiler messages.

HISTORY

  0.01 First release

INSTALLATION

This module is shipped as a basic PM file that should be installed in your site\lib dir. This module should work in any Perl port that has the Archive::Tar module.

DEPENDENCIES

Archive::Tar must be installed for this module to function. Archive::Tar is used as the principle method for the creation and reading of data files.

DESCRIPTION

To use this module put the following line at the beginning of your script:

        use PlugIn;

Any one of the functions can be referenced by:

        var = PlugIn::function

RETURN VALUES

Unless otherwise specified, all functions return undef if unsuccessful and non-zero data if successful.

FUNCTIONS

The following functions are available, but not exported.

PlugIn::Open

        PlugIn::Open($file, $optswitch);

Opens a data file (TAR.GZ), requires it, and then deletes the extracted files by default. The code in each required file is automatically executed and included subroutines are available.

        $file is the filename of the data file to be opened
        $optswitch is an optional boolean switch to prevent deletion of the extracted files

PlugIn::OpenEval

        PlugIn::OpenEval($file, $optswitch);

Opens a data file (TAR.GZ), evaluates it, and then deletes the extracted files by default. The code in each required file is automatically executed and included subroutines are available. The evaluation routine should hide run-time compiler messages.

        $file is the filename of the data file to be opened
        $optswitch is an optional boolean switch to prevent deletion of the extracted files

PlugIn::Read

        %hash = PlugIn::Read($file, $optswitch);

Opens a data file (TAR.GZ), extracts the contents, and then deletes them by default. The code is returned in the specified hash.

        %hash is the returned data with the keys listed as the extracted filename
        $hash{filename} is the contents of the specified extracted file

        $file is the filename of the data file to be opened
        $optswitch is an optional boolean switch to prevent deletion of the extracted files

Read is provided as an accessor method if you want to add your own processing to the data before requiring it. The data could be encrypted or otherwise obscured.

PlugIn::Write

        @list = PlugIn::Write($datfile, @files);
        $files = PlugIn::Write($datfile, @files);

Creates a new data file (TAR.GZ), with the specified list of files.

        @list - in list context it returns the names of files added to the data file
        $files - in scalar context it returns the number of files added to the data file

        $datfile is the name of the data file to be created
        @files is the list of file to be added to the archive

If you wish to store encrypted or obscured code, the input files must already be in this condition.

PlugIn::WriteEval

        @list = PlugIn::WriteEval($datfile, @files);
        $files = PlugIn::WriteEval($datfile, @files);

Before the data file is created, each file in the filelist is first evaluated for errors. If all files evaluate successfully then a new data file (TAR.GZ) is created. Files are evaluated through the use of the PlugIn::EvalIt function.

        @list - in list context it returns the names of files added to the data file
        $files - in scalar context it returns the number of files added to the data file

        $datfile is the name of the data file to be created
        @files is the list of file to be added to the archive

PlugIn::EvalIt

        PlugIn::EvalIt(@files);

The passed data is evaluated using Perl's 'eval' function and returns true only if all data passes. While this serves to provide some quality assurance, it also servers to hide run-time compiler messages in the commercial Perl to EXE compilers.

        @files is the list of files to be evaluated

Based on code by Indy Singh of WWW.DEMOBUILDER.COM (Perl2EXE)

AUTHOR

Brad Turner ( bsturner@sprintparanet.com ).