plc - Convert Perl program into a .NET application
plc [options] perlscript
plc [options] project
plc
plc --help
plc --version
The PerlNET utility converts a Perl program into a .NET application. This utility combines a Perl program, all of the required Perl modules and a modified Perl interpreter into one binary unit. When the resulting application is run, it searches for modules within itself before searching the filesystem.
Most commonly, PerlNET is invoked with the name of the Perl program that you want converted as an argument. This produces a working application. Some of the options described below make it possible to control which modules are included and how the generated application behaves.
If PerlNET is invoked without arguments, the graphical interface is
displayed. If invoked with the --version or --help option, it will print
the corresponding message and exit.
The following command-line options are supported. Options can be abbreviated for uniqueness (shortened only to the point that they are still distinct from other options).
@, then PerlNET
replaces each one of these with the arguments parsed from the corresponding
file.
plc myscript.pl --add IO::Socket --add XML::Parser::Expat
...would include IO::Socket and XML::Parser in your application.
PerlNET::get_bound_file() and
PerlNET::extract_bound_file() functions. Separate multiple filenames with
semicolons. This option can be repeated.
Additional options can be specified after the filename, within brackets and separated by commas:
name[option1,option2,...]
Valid options are:
data. If neither file nor data is specified, then the
bound name is used as the filesystem name as well.
file.
TEMP directory upon application start.
It is deleted when the application terminates. The extraction directory is
added to the PATH environment variable. It is also added to the front of
@INC.
extract
option or the PerlNET::extract_bound_file() function. File permissions must
be specified as an octal number (0555 by default); PerlNET implicitly calls
chmod() after extracting the file to make sure it ends up with the right
permission bits. The mode= prefix is optional.
Examples:
--bind PerlEz.dll[file=\perl\bin\PerlEz.dll,extract]
--bind data.txt[text,0777]
Note: Files bound using the extract suboption of --bind or extracted
via PerlNET::extract_bound_file() are written to a a per-process temporary
directory and are automatically deleted when the process ends. This occurs
regardless of whether the --clean option is used.
--lib, but it searches for a MakeMaker-like blib directory
structure starting in libpath and working back up to five levels of '..'. If
found, it adds both the lib and the arch part of the blib structure to
the module search path.
The special port name ':komodo' provides support for remote debugging with
the ActiveState Komodo IDE (version 1.2 and later,
http://www.ActiveState.com/Komodo). Komodo uses a custom version of
perl5db.pl. The path to this file must be made available to the application
either via the PERL5LIB environment variable (for dependent applications) or
via the --lib PerlNET command-line option (for freestanding
applications). For example:
plc --lib /path-to/komodo-1.2/perl/site/lib ...
Refer to the Komodo Remote Debugging documentation for additional information.
Modules loaded from the directories specified with a --lib or --blib
option are still included. This allows you to selectively include only some
non-standard modules in your PerlNET generated application.
If the argument for --exe ends with ".app" (i.e. is a Mac OS X application),
the --gui option is implied.
Multiple modules can be separated by whitespace or semi-colons. The special
value all will make PerlNET explain all files it includes.
--dependent option to
built a non-freestanding application.
--target winexe, but provided for compatibility with PerlApp.
plc --help FUNCTIONS
plc --help bind
The filename given must be an .ico, .dll or .exe filename. For
.dll and .exe files, the name can be followed by a comma and the icon
number. The first icon in the file is ,0, the second ,1, etc. If the
icon number is not provided, then ,0 is assumed. Separated multiple
filenames with semicolons. This option can be repeated.
All values are taken as strings except FileVersion and ProductVersion,
which must be in the form 'W.X.Y.Z' (where W, X, Y, and Z are numbers in the
range 0-65535. X, Y, and Z are optional and default to 0).
PATH environment variable. This option can be
repeated.
PerlNET will automatically add architecture and version specific
subdirectories the same way the Perl -I option and the Perl lib pragma
do.
The content of the PERL5LIB environment variable is automatically added via
an implicit --lib option.
--runlib option because
the default runlib location is the directory where the application is stored.
--exe option.
--gui option on OS X changes this to
<Application>.app/Contents/MacOS/.
The --norunlib option can be used to specify that no runlib directory should
be used.
The runlib directory is also used to locate shared library files specified
using the --use option.
The fully qualified path to the runlib directory is stored in the
$PerlNET::RUNLIB variable.
This option is being used to create a shared library that can be referenced by
other applications with the --use option.
The --shared option must be used to grant other programs access to modules
bundled in the current executable.
If no --script option is specified, the argument to PerlNET is assumed to
be the input script filename. Thus
plc myscript.pl
...is equivalent to:
plc --script myscript.pl
The "private" mode allows applications built with the same PDK license to access any bundled modules. This means that part of the license serial number is encoded in the generated executable. The accessing application must then also be built using the "private" sharing mode to enable serial number matching.
Shared libraries built with the "public" sharing mode can be accessed by all executables built by the PDK without restriction.
exe, winexe or library. The default target is exe.
Note: PerlNET does not automatically create this directory; it must exist before the application is run.
Multiple modules can be separated by whitespace or a semicolon. This option can be repeated.
If a command explicitly adds and removes modules at the same time, modules
added with --add will not be removed by --trim.
The --trim option supports the following wildcard notations: --trim
Module::* excludes Module::Foo, but neither Module itself nor
Module::Foo::Bar. --trim Module::** excludes Module::Foo and
Module::Foo::Bar, but not Module. --trim Module:: works the same as
--trim Module;Module::**, excluding all of Module, Module::Foo and
Module::Foo::Bar. Note that you may have to quote the * character to
prevent wildcard expansion by your command shell.
Errno
File::Glob
PerlIO
PerlIO::scalar
attributes
You can also use the --trim option to exclude these modules on a one-by-one
basis.
The libname argument can be specified using a full path name. At runtime,
the library is located in the runtime library directory specified by the
--runlib option. If the library cannot be found, the executable will not
run.
If the shared library has been built as a "private" shared library, the
application that is using it must be built with the "private" --shared
option too.
Separte multiple libnames with semicolons. The option can be repeated.
Output lines prefixed with +++ are modules that were included. Lines
prefixed with --- are dependent modules that were not included.
The --verbose option automatically enables --warnings as well.
The following functions are made available to the application created by
PerlNET. They are available via the PerlApp:: namespace in addition to
PerlNET::, to simplify sharing modules between PerlApp applications and
PerlNET applications.
my $datafile = "data.txt";
my $filename = PerlNET::extract_bound_file($datafile);
die "$datafile not bound to application\n" unless defined $filename;
open(my $fh, $filename) or die "Can't open $datafile($filename)\n";
If the file is not bound, no file is created and extract_bound_file()
returns undef.
extract_bound_file() always writes files in binmode. Therefore files
bound with the [text] option are extracted with \n and not \r\n line
endings.
--bind
command-line option. Returns the whole file as a single string in scalar
context or separate lines in list context, in which case lines are always split
on newline (i.e. $/ is not considered).
foreach my $line (PerlNET::get_bound_file("data.txt")) {
# ... process $line ...
}
If the file is not bound, get_bound_file() returns undef in scalar
context or the empty list in list context.
The following predefined variables are available to the application created by PerlNET.
All PerlNET:: variables documented here are also available via the
PerlApp:: namespace
$PerlNET::BUILD variable contains the PerlNET build number.
$PerlNET::PERL5LIB variable contains the value of the PERL5LIB
environment variable. If that does not exist, it contains the value of the
PERLLIB environment variable. If that one does not exists either,
$PerlNET::PERL5LIB is undef.
$PerlNET::RUNLIB variable contains the fully qualified path name to the
runtime library directory specified by the --runlib option. If the
--norunlib option is used, this variable is undef.
$PerlNET::TOOL variable contains the string: "PerlNET", indicating that
the currently running executable has been produced by the PerlNET tool.
$PerlNET::VERSION variable contains the PerlNET version number:
"major.minor.release", but not including the build number.
When the application built with PerlNET runs, it extracts its dynamic object
files in the pdk-username subdirectory of the temporary directory. The
temporary directory is located using the TEMP environment variable. It is
also possible to hardcode the location with the --tmpdir command-line
option.
If the application was built using the --clean option, PerlNET also appends
the process id to the username when creating the temporary directory (e.g.,
pdk-username-1234). This avoids race conditions during cleanup. Unless the
--clean option is used, extracted files are left behind when the application
terminates. They are reused by later incarnations of the same application (or
by other PDK-created executables).
PerlNET uses the PERLNET_OPT environment variable to set default
command-line options. PerlNET treats these options as if they were specified
at the beginning of every PerlNET command line. Note: Perl must be in your
PATH if you want to use PERLNET_OPT.
All directories specified in the PERL5LIB environment variable are treated
as if they had been specified with the --lib command-line option. Therefore
modules located in PERL5LIB directories will be included even in dependent
applications. If PERL5LIB is not set, PerlNET will use the value of
PERLLIB instead (just like regular Perl).
PerlNET will pipe the output of plc --help through the program specified
in the PAGER environment variable if STDOUT is a terminal.
The following environment variables are not visible to the application built
with PerlNET: PERL5LIB, PERLLIB, PERL5OPT, PERL5DB and
PERL5SHELL.
The temporary extraction directory is automatically added to the PATH
environment variable when a file is bound using the [extract] option.
When PerlNET can't locate a module that seems to be used or required by the application, it produces an error message:
VMS\Stdio.pm:
warn: Can't locate VMS\Stdio.pm
refby: C:\perl\lib\File\Temp.pm
In general, PerlNET cannot determine whether a module is absolutely needed at runtime. For the error message above, looking at the source code of the File::Temp module reveals that the VMS::Stdio module is only used on the VMS platform:
require VMS::Stdio if $^O eq 'VMS';
It is therefore safe to ignore the error. PerlNET includes a number of platform-specific rules telling it that certain dependencies are likely not required. In those cases, the error messages are downgraded to a warning. In all other cases it is the responsibility of the user to verify if the module is needed or not. PerlNET still generates a valid executable, even while this error message is displayed.
It is possible to suppress the error/warning message by explicitly excluding
the missing module with the --trim option:
--trim VMS::Stdio
Windows uses case-insensitive filesystems. It is often possible to misspell a module name and still have Perl load the correct file. For example:
use Win32::Eventlog;
...loads the Win32::EventLog module, but it does not import any
symbols from it: Perl tries to call the
Win32::Eventlog->import() method, which doesn't exist, and
gives up. PerlNET on Windows generates an error when
the file name and the module name cases don't match:
Win32\Eventlog.pm:
error: Case mismatch between module and file name
file: C:\perl\site\lib\Win32\EventLog.pm
auto\Win32\Eventlog\Eventlog.dll:
error: Case mismatch between module and file name
file: C:\perl\site\lib\auto\Win32\EventLog\EventLog.dll
It is important to either correct the wrong spelling in the program or rename the file on disk to the correct name as PerlNET internally uses a case-sensitive file name lookup and otherwise does not load the file at runtime.
PerlNET sometimes needs to include additional module-specific data files.
When the module is installed both into the standard Perl library tree and into
an additional location added either via the --lib option or PERL5LIB
environment variable, the data file will be found twice (but only included
once). The same problem can happen when the standard Perl library directories
are specified again using --lib or PERL5LIB. The error message should
display both the original and the duplicate filenames:
Tk\srcfile.xpm:
error: Skipping duplicate file D:\perl\site\lib\Tk\srcfile.xpm
file: C:\perl\site\lib\Tk\srcfile.xpm
Please make sure that you don't include modules from a library created for a different version of Perl unless you are sure that it is binary compatible.
This section answers some frequently asked questions about PerlNET.
The first thing PerlNET needs to do is to determine which modules and
external files the converted script depends upon. The PerlNET program starts
out by scanning the source code of the script. When it finds occurrences of
use, do or require, it tries to locate the corresponding module and
then parse the source of that module. This continues as long as PerlNET
finds new modules to examine.
PerlNET does not try to run the script. It will not automatically determine which modules might be loaded by a statement such as:
require $module;
In cases like this, try listing additional modules to traverse with the
--add option.
The PerlNET program has some built-in heuristics for major Perl modules that
determine additional modules at runtime, like DBI, LWP, Tk. PerlNET
anticipates which additional modules are required so that they are available in
freestanding executables.
PerlNET then decides which modules to include in the generated application.
Normally, all located modules are included. This also includes the dynamic
object files (.so/.dll) and AutoLoader files (.al) that go with the located
modules. If the --dependent option is used, only modules located under the
directories given by the --lib option are included.
Finally, the application is built with all the modules compressed (unless the
--nocompress option is used) and included. When the application runs it
arranges for any use, do and require statements to look for and
extract the corresponding modules in itself.
It can check for the $PerlNET::VERSION variable. It will be set to the
version number of PerlNET that was used to build the executable.
It will always have the value: perl. The $^X is a special variable that
normally contains the filename of the Perl interpreter that is executing the
script. It is sometimes used in calls to system or exec to invoke perl from
within the script.
No. PerlNET does not support modules using source filters (e.g. Switch, Filter::Util, and Filter::cpp). See perlfilter in the ActivePerl documentation or 'perldoc perlfilter' for more information on source filters in perl.
Visit http://www.ActiveState.com/Products/Perl_Dev_Kit/ to obtain a license for PDK 7.3.
The application built with PerlNET running with an evaluation license
expires when the evaluation license times out. Use the --version option to
view the time limit of your current license.
perl(1)
PerlNET is part of the Perl Dev Kit. More information available at http://www.ActiveState.com/PerlDevKit/Purchase
This manpage documents PerlNET version 7.3.0 (build 287465)
Copyright (C) 1998-2008 ActiveState Software Inc. All rights reserved.