<LI><A HREF="#i cannot run external programs">I cannot run external programs</A></LI>
<LI><A HREF="#i cannot embed perl into my program, or use perl.dll from my">I cannot embed perl into my program, or use <EM>perl.dll</EM> from my</A></LI>
<LI><A HREF="#`` and pipeopen do not work under dos."><CODE>``</CODE> and pipe-<A HREF="../../lib/Pod/perlfunc.html#item_open"><CODE>open</CODE></A> do not work under DOS.</A></LI>
man <A HREF="../../lib/Pod/perlrun.html">perlrun</A>
view cmdref extproc
help extproc</PRE>
<P>or whatever method you prefer.</P>
<P>There are also endless possibilities to use <EM>executable extensions</EM> of
4os2, <EM>associations</EM> of WPS and so on... However, if you use
*nixish shell (like <EM>sh.exe</EM> supplied in the binary distribution),
you need to follow the syntax specified in <A HREF="../../lib/Pod/perlrun.html#switches">Switches in the perlrun manpage</A>.</P>
<P>Note that <STRONG>-S</STRONG> switch enables a search with additional extensions
<EM>.cmd</EM>, <EM>.btm</EM>, <EM>.bat</EM>, <EM>.pl</EM> as well.</P>
<P>
<H2><A NAME="starting os/2 (and dos) programs under perl">Starting OS/2 (and DOS) programs under Perl</A></H2>
<P>This is what <A HREF="../../lib/Pod/perlfunc.html#item_system"><CODE>system()</CODE></A> (see <A HREF="../../lib/Pod/perlfunc.html#system">system in the perlfunc manpage</A>), <CODE>``</CODE> (see
<A HREF="../../lib/Pod/perlop.html#i/o operators">I/O Operators in the perlop manpage</A>), and <EM>open pipe</EM> (see <A HREF="../../lib/Pod/perlfunc.html#open">open in the perlfunc manpage</A>)
are for. (Avoid <A HREF="../../lib/Pod/perlfunc.html#item_exec"><CODE>exec()</CODE></A> (see <A HREF="../../lib/Pod/perlfunc.html#exec">exec in the perlfunc manpage</A>) unless you know what you
do).</P>
<P>Note however that to use some of these operators you need to have a
sh-syntax shell installed (see <A HREF="#pdksh">Pdksh</A>,
<A HREF="#frequently asked questions">Frequently asked questions</A>), and perl should be able to find it
(see <A HREF="#perl_sh_dir">PERL_SH_DIR</A>).</P>
<P>The cases when the shell is used are:</P>
<OL>
<LI>
One-argument <A HREF="../../lib/Pod/perlfunc.html#item_system"><CODE>system()</CODE></A> (see <A HREF="../../lib/Pod/perlfunc.html#system">system in the perlfunc manpage</A>), <A HREF="../../lib/Pod/perlfunc.html#item_exec"><CODE>exec()</CODE></A> (see <A HREF="../../lib/Pod/perlfunc.html#exec">exec in the perlfunc manpage</A>)
with redirection or shell meta-characters;
<P></P>
<LI>
Pipe-open (see <A HREF="../../lib/Pod/perlfunc.html#open">open in the perlfunc manpage</A>) with the command which contains redirection
or shell meta-characters;
<P></P>
<LI>
Backticks <CODE>``</CODE> (see <A HREF="../../lib/Pod/perlop.html#i/o operators">I/O Operators in the perlop manpage</A>) with the command which contains
redirection or shell meta-characters;
<P></P>
<LI>
If the executable called by system()/exec()/pipe-open()/<CODE>``</CODE> is a script
with the ``magic'' <CODE>#!</CODE> line or <CODE>extproc</CODE> line which specifies shell;
<P></P>
<LI>
If the executable called by system()/exec()/pipe-open()/<CODE>``</CODE> is a script
without ``magic'' line, and <CODE>$ENV{EXECSHELL}</CODE> is set to shell;
<P></P>
<LI>
If the executable called by system()/exec()/pipe-open()/<CODE>``</CODE> is not
found;
<P></P>
<LI>
For globbing (see <A HREF="../../lib/Pod/perlfunc.html#glob">glob in the perlfunc manpage</A>, <A HREF="../../lib/Pod/perlop.html#i/o operators">I/O Operators in the perlop manpage</A>).
<P></P></OL>
<P>For the sake of speed for a common case, in the above algorithms
backslashes in the command name are not considered as shell metacharacters.</P>
<P>Perl starts scripts which begin with cookies
<CODE>extproc</CODE> or <CODE>#!</CODE> directly, without an intervention of shell. Perl uses the
same algorithm to find the executable as <EM>pdksh</EM>: if the path
on <CODE>#!</CODE> line does not work, and contains <CODE>/</CODE>, then the executable
is searched in <EM>.</EM> and on <A HREF="../../lib/Pod/perlrun.html#item_PATH"><CODE>PATH</CODE></A>. To find arguments for these scripts
Perl uses a different algorithm than <EM>pdksh</EM>: up to 3 arguments are
recognized, and trailing whitespace is stripped.</P>
<P>If a script
does not contain such a cooky, then to avoid calling <EM>sh.exe</EM>, Perl uses
the same algorithm as <EM>pdksh</EM>: if <CODE>$ENV{EXECSHELL}</CODE> is set, the
script is given as the first argument to this command, if not set, then
<CODE>$ENV{COMSPEC} /c</CODE> is used (or a hardwired guess if <CODE>$ENV{COMSPEC}</CODE> is
not set).</P>
<P>If starting scripts directly, Perl will use exactly the same algorithm as for
the search of script given by <STRONG>-S</STRONG> command-line option: it will look in
the current directory, then on components of <CODE>$ENV{PATH}</CODE> using the
following order of appended extensions: no extension, <EM>.cmd</EM>, <EM>.btm</EM>,
<EM>.bat</EM>, <EM>.pl</EM>.</P>
<P>Note that Perl will start to look for scripts only if OS/2 cannot start the
specified application, thus <CODE>system 'blah'</CODE> will not look for a script if
there is an executable file <EM>blah.exe</EM> <EM>anywhere</EM> on <A HREF="../../lib/Pod/perlrun.html#item_PATH"><CODE>PATH</CODE></A>.</P>
<P>Note also that executable files on OS/2 can have an arbitrary extension,
but <EM>.exe</EM> will be automatically appended if no dot is present in the name.
The workaround as as simple as that: since <EM>blah.</EM> and <EM>blah</EM> denote the
same file, to start an executable residing in file <EM>n:/bin/blah</EM> (no
extension) give an argument <CODE>n:/bin/blah.</CODE> to system().</P>
<P>The last note is that currently it is not straightforward to start PM
programs from VIO (=text-mode) Perl process and visa versa. Either ensure
that shell will be used, as in <CODE>system 'cmd /c epm'</CODE>, or start it using
optional arguments to <A HREF="../../lib/Pod/perlfunc.html#item_system"><CODE>system()</CODE></A> documented in <CODE>OS2::Process</CODE> module. This
<H2><A NAME="i cannot run external programs">I cannot run external programs</A></H2>
<DL>
<DT><DD>
Did you run your programs with <CODE>-w</CODE> switch? See
<EM>Starting OS/2 (and DOS) programs under Perl</EM>.
<P></P>
<DT><DD>
Do you try to run <EM>internal</EM> shell commands, like <CODE>`copy a b`</CODE>
(internal for <EM>cmd.exe</EM>), or <CODE>`glob a*b`</CODE> (internal for ksh)? You
need to specify your shell explicitly, like <CODE>`cmd /c copy a b`</CODE>,
since Perl cannot deduce which commands are internal to your shell.
<P></P></DL>
<P>
<H2><A NAME="i cannot embed perl into my program, or use perl.dll from my program.">I cannot embed perl into my program, or use <EM>perl.dll</EM> from my
program.</A></H2>
<DL>
<DT><STRONG><A NAME="item_Is_your_program_EMX%2Dcompiled_with_%2DZmt_%2DZcrt">Is your program EMX-compiled with <CODE>-Zmt -Zcrtdll</CODE>?</A></STRONG><BR>
<DD>
If not, you need to build a stand-alone DLL for perl. Contact me, I
did it once. Sockets would not work, as a lot of other stuff.
<P></P>
<DT><STRONG><A NAME="item_Did_you_use_ExtUtils%3A%3AEmbed%3F">Did you use <A HREF="../../lib/ExtUtils/Embed.html">the ExtUtils::Embed manpage</A>?</A></STRONG><BR>
<DD>
I had reports it does not work. Somebody would need to fix it.
<P></P></DL>
<P>
<H2><A NAME="`` and pipeopen do not work under dos."><CODE>``</CODE> and pipe-<A HREF="../../lib/Pod/perlfunc.html#item_open"><CODE>open</CODE></A> do not work under DOS.</A></H2>
<P>This may a variant of just <A HREF="#i cannot run external programs">I cannot run external programs</A>, or a
deeper problem. Basically: you <EM>need</EM> RSX (see <A HREF="#prerequisites">Prerequisites</A>)
for these commands to work, and you may need a port of <EM>sh.exe</EM> which
understands command arguments. One of such ports is listed in
<A HREF="#prerequisites">Prerequisites</A> under RSX. Do not forget to set variable
<P>If you do not change this directory, do nothing. Otherwise put this
directory and subdirectory <EM>./os2</EM> in <A HREF="../../lib/Pod/perlrun.html#item_PERLLIB"><CODE>PERLLIB</CODE></A> or <A HREF="../../lib/Pod/perlrun.html#item_PERL5LIB"><CODE>PERL5LIB</CODE></A>
variable. Do not use <A HREF="../../lib/Pod/perlrun.html#item_PERL5LIB"><CODE>PERL5LIB</CODE></A> unless you have it set already. See
<A HREF="../../lib/Pod/perl.html#environment">ENVIRONMENT in the perl manpage</A>.</P>
<DT><STRONG><A NAME="item_Tools_to_compile_Perl_modules">Tools to compile Perl modules</A></STRONG><BR>
<DD>
<PRE>
unzip perl_blb.zip -d f:/perllib/lib</PRE>
<P>If this directory is preserved, you do not need to change
anything. However, for perl to find it if it is changed, you need to
<CODE>set PERLLIB_PREFIX</CODE> in <EM>Config.sys</EM>, see <A HREF="#perllib_prefix">PERLLIB_PREFIX</A>.</P>
<DT><STRONG><A NAME="item_Manpages_for_Perl_and_utilities">Manpages for Perl and utilities</A></STRONG><BR>
<DD>
<PRE>
unzip perl_man.zip -d f:/perllib/man</PRE>
<P>This directory should better be on <CODE>MANPATH</CODE>. You need to have a
working man to access these files.</P>
<DT><STRONG><A NAME="item_Manpages_for_Perl_modules">Manpages for Perl modules</A></STRONG><BR>
<DD>
<PRE>
unzip perl_mam.zip -d f:/perllib/man</PRE>
<P>This directory should better be on <CODE>MANPATH</CODE>. You need to have a
working man to access these files.</P>
<DT><STRONG><A NAME="item_Source_for_Perl_documentation">Source for Perl documentation</A></STRONG><BR>
<DD>
<PRE>
unzip perl_pod.zip -d f:/perllib/lib</PRE>
<P>This is used by by <CODE>perldoc</CODE> program (see <EM>perldoc</EM>), and may be used to
generate HTML documentation usable by WWW browsers, and
documentation in zillions of other formats: <CODE>info</CODE>, <CODE>LaTeX</CODE>,
<CODE>Acrobat</CODE>, <CODE>FrameMaker</CODE> and so on.</P>
<DT><STRONG><A NAME="item_Perl_manual_in_%2EINF_format">Perl manual in <EM>.INF</EM> format</A></STRONG><BR>
<DD>
<PRE>
unzip perl_inf.zip -d d:/os2/book</PRE>
<P>This directory should better be on <CODE>BOOKSHELF</CODE>.</P>
<P>Since Perl processes the <CODE>#!</CODE>-line (cf.
<A HREF="../../lib/Pod/perlrun.html#description">DESCRIPTION in the perlrun manpage</A>, <A HREF="../../lib/Pod/perlrun.html#switches">Switches in the perlrun manpage</A>,
<A HREF="../../lib/Pod/perldiag.html#not a perl script">Not a perl script in the perldiag manpage</A>,
<A HREF="../../lib/Pod/perldiag.html#no perl script found in input">No Perl script found in input in the perldiag manpage</A>), it should know when a
program <EM>is a Perl</EM>. There is some naming convention which allows
Perl to distinguish correct lines from wrong ones. The above names are
almost the only names allowed by this convention which do not contain
digits (which have absolutely different semantics).</P>
<H2><A NAME="tmp or temp"><CODE>TMP</CODE> or <CODE>TEMP</CODE></A></H2>
<P>Specific for EMX port. Used as storage place for temporary files, most
notably <CODE>-e</CODE> scripts.</P>
<P>
<HR>
<H1><A NAME="evolution">Evolution</A></H1>
<P>Here we list major changes which could make you by surprise.</P>
<P>
<H2><A NAME="priorities">Priorities</A></H2>
<P><A HREF="../../lib/Pod/perlfunc.html#item_setpriority"><CODE>setpriority</CODE></A> and <A HREF="../../lib/Pod/perlfunc.html#item_getpriority"><CODE>getpriority</CODE></A> are not compatible with earlier
ports by Andreas Kaiser. See <CODE>"setpriority, getpriority"</CODE>.</P>
<P>
<H2><A NAME="dll name mangling">DLL name mangling</A></H2>
<P>With the release 5.003_01 the dynamically loadable libraries
should be rebuilt. In particular, DLLs are now created with the names
which contain a checksum, thus allowing workaround for OS/2 scheme of
caching DLLs.</P>
<P>
<H2><A NAME="threading">Threading</A></H2>
<P>As of release 5.003_01 perl is linked to multithreaded CRT
DLL. If perl itself is not compiled multithread-enabled, so will not be perl
malloc(). However, extensions may use multiple thread on their own
risk.</P>
<P>Needed to compile <CODE>Perl/Tk</CODE> for XFree86-OS/2 out-of-the-box.</P>
<P>
<H2><A NAME="calls to external programs">Calls to external programs</A></H2>
<P>Due to a popular demand the perl external program calling has been
changed wrt Andreas Kaiser's port. <EM>If</EM> perl needs to call an
external program <EM>via shell</EM>, the <EM>f:/bin/sh.exe</EM> will be called, or
whatever is the override, see <A HREF="#perl_sh_dir">PERL_SH_DIR</A>.</P>
<P>Thus means that you need to get some copy of a <EM>sh.exe</EM> as well (I
use one from pdksh). The drive <EM>F:</EM> above is set up automatically during
the build to a correct value on the builder machine, but is
overridable at runtime,</P>
<P><STRONG>Reasons:</STRONG> a consensus on <CODE>perl5-porters</CODE> was that perl should use
one non-overridable shell per platform. The obvious choices for OS/2
are <EM>cmd.exe</EM> and <EM>sh.exe</EM>. Having perl build itself would be impossible
with <EM>cmd.exe</EM> as a shell, thus I picked up <CODE>sh.exe</CODE>. Thus assures almost
100% compatibility with the scripts coming from *nix. As an added benefit
this works as well under DOS if you use DOS-enabled port of pdksh
(see <A HREF="#prerequisites">Prerequisites</A>).</P>
<P><STRONG>Disadvantages:</STRONG> currently <EM>sh.exe</EM> of pdksh calls external programs
via fork()/exec(), and there is <EM>no</EM> functioning <A HREF="../../lib/Pod/perlfunc.html#item_exec"><CODE>exec()</CODE></A> on
OS/2. <A HREF="../../lib/Pod/perlfunc.html#item_exec"><CODE>exec()</CODE></A> is emulated by EMX by asyncroneous call while the caller
waits for child completion (to pretend that the <CODE>pid</CODE> did not change). This
means that 1 <EM>extra</EM> copy of <EM>sh.exe</EM> is made active via fork()/exec(),
which may lead to some resources taken from the system (even if we do
not count extra work needed for fork()ing).</P>
<P>Note that this a lesser issue now when we do not spawn <EM>sh.exe</EM>
unless needed (metachars found).</P>
<P>One can always start <EM>cmd.exe</EM> explicitly via</P>
<PRE>
system 'cmd', '/c', 'mycmd', 'arg1', 'arg2', ...</PRE>
<P>If you need to use <EM>cmd.exe</EM>, and do not want to hand-edit thousands of your
scripts, the long-term solution proposed on p5-p is to have a directive</P>
<PRE>
use OS2::Cmd;</PRE>
<P>which will override system(), exec(), <CODE>``</CODE>, and
<A HREF="../../lib/Pod/perlfunc.html#item_open"><CODE>open(,'...|')</CODE></A>. With current perl you may override only system(),
<A HREF="../../lib/Pod/perlfunc.html#item_readpipe"><CODE>readpipe()</CODE></A> - the explicit version of <CODE>``</CODE>, and maybe exec(). The code
will substitute the one-argument call to <A HREF="../../lib/Pod/perlfunc.html#item_system"><CODE>system()</CODE></A> by