Main Site Contents Up Previous Next

Utility Functions

Cava::Packager::GetScriptCommand($scriptname, $perloptions, @args);

Accepts a script-name, a reference to Perl options or a scalar string containing Perl options, and any arguments to the script. Returns an appropriate command line whether the script is running packaged or under Perl.

Returns a string in a scalar context. An array in a list context;

Cava Packager allows you to package many scripts as executables, sharing the same packaged Modules and libraries. For example, in Cava Packager itself, two scripts are packaged:

The script is called from to scan and build projects. In development, our module tree is at ../cavalib relative to the script location. To run, we do:

my @commandparts = Cava::Packager::GetScriptCommand('', ['-I../cavalib'], @myargs);

Running under Perl this returns:

( $^X, '-I../cavalib', @myargs)

or in a scalar context

'$^X -I../cavalib arg1 arg2 arg3'

Running when packaged it returns:

( $fullpathtocavaconsoleexe, @myargs)

or in a scalar context

'/full/path/cavaconsole arg1 arg2 arg3'

In the packaged application, the Perl options are dropped. We also do not have to care what the packaged executable is called or where it is in the final distribution tree. If $^X or $pathtopackagedexecutable contains spaces, it is quoted. All other params are returned unaltered.


Returns the current username. Under MS Windows, returns the current login. Under MacOSX and Linux, returns the effective user as given by (getpwuid($<))[0]


Returns true if the OS is Windows. False otherwise.


Returns true if the OS is Linux. False otherwise


Returns true if the OS is MacOSX. False otherwise.


Returns true if the application is running as a package cava app. False if running standard Perl.


Returns true if the packaged executable was packed with the GUI flag set to true. False otherwise. Always returns false if running under standard Perl.

Contents Up Previous Next

Cava Packager Copyright © 2006-2012 Mark Dootson