home *** CD-ROM | disk | FTP | other *** search
/ Chip: Windows 2000 Professional Resource Kit / W2KPRK.iso / apps / perl / ActivePerl.exe / data.z / perlwin32faq5.html < prev    next >
Encoding:
Extensible Markup Language  |  1999-10-15  |  17.6 KB  |  474 lines

  1. <?xml version="1.0"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3.     "http://www.w3.org/TR/xhtml1/DTD/transitional.dtd">
  4. <html xmlns="http://www.w3.org/TR/xhtml1">
  5.   <head>
  6.     <title>perlwin32faq5 - Implementation Quirks</title>
  7.     <link rev="made" href="mailto:bjepson@debian.ids.net" />
  8.     <meta name="GENERATOR" charset="iso-8859-1" />
  9.     <link rel="STYLESHEET" href="../win32prk.css" type="text/css"
  10.     media="screen" />
  11.   </head>
  12.  
  13.   <body bgcolor="#ffffff">
  14.     <!-- beginning of leaf header-->
  15.  
  16.     <table width="100%">
  17.       <tr>
  18.         <td bgcolor="000000" width="70" height="31"><a href= 
  19.         "http://www.activestate.com/"><img src="ASbutton.gif" alt= 
  20.         "ActiveState Home Page" border="0" width="68" height=
  21.         "30" /></a></td>
  22.  
  23.         <td width="10" bgcolor="#ffffff"> </td>
  24.  
  25.         <td valign="middle" bgcolor="#cc0066"><font face=
  26.         "sans-serif" size="+1" color="#ff99cc">   
  27.         Win32 FAQ</font></td>
  28.       </tr>
  29.     </table>
  30.     <!-- end of leaf content--><!-- INDEX BEGIN -->
  31.  
  32.     <ul>
  33.       <li><a href="#NAME">NAME</a></li>
  34.  
  35.       <li>
  36.         <a href="#DESCRIPTION">DESCRIPTION</a> 
  37.  
  38.         <ul>
  39.           <li><a href="#Certain_functions_don_t_seem_to_">Certain
  40.           functions don't seem to work on Perl for Win32.</a></li>
  41.  
  42.           <li><a href="#The_exec_function_doesn_t_seem_t">The exec
  43.           function doesn't seem to work under Perl for ISAPI, Perl
  44.           for WebSite, or PerlScript. Why not?</a></li>
  45.  
  46.           <li><a href="#What_s_the_difference_between_Pe">What's
  47.           the difference between Perl for Win32 and the old 3xx
  48.           builds?</a></li>
  49.  
  50.           <li><a href="#What_s_the_difference_between_ru">What's
  51.           the difference between running Perl for Win32 on Windows
  52.           NT</a></li>
  53.  
  54.           <li><a href="#Why_don_t_the_examples_from_the_">Why don't
  55.           the examples from the Camel book work?</a></li>
  56.  
  57.           <li><a href="#Why_don_t_certain_standard_libra">Why don't
  58.           certain standard library modules work?</a></li>
  59.  
  60.           <li><a href="#How_do_I_make_a_UNIX_based_scrip">How do I
  61.           make a UNIX-based script work?</a></li>
  62.  
  63.           <li><a href="#How_does_the_chmod_function_work">How does
  64.           the chmod function work on Win32 platforms?</a></li>
  65.  
  66.           <li><a href="#4DOS_doesn_t_recognize_on_the">4DOS doesn't
  67.           recognize \" on the command line.</a></li>
  68.  
  69.           <li><a href="#STDIN_and_STDOUT_and_Piping_don">STDIN and
  70.           STDOUT, and Piping don't always work on NT.</a></li>
  71.  
  72.           <li><a href="#Signal_Handling">Why doesn't signal
  73.           handling work on Windows.</a></li>
  74.         </ul>
  75.       </li>
  76.  
  77.       <li><a href="#AUTHOR_AND_COPYRIGHT">AUTHOR AND
  78.       COPYRIGHT</a></li>
  79.     </ul>
  80.     <!-- INDEX END -->
  81.     <hr />
  82.     <br />
  83.  
  84.     <h1><a name="NAME">NAME</a></h1>
  85.  
  86.     <p>perlwin32faq5 - Implementation Quirks</p>
  87.     <br />
  88.     <hr />
  89.  
  90.     <h1><a name="DESCRIPTION">DESCRIPTION</a></h1>
  91.  
  92.     <p>Issues specific to the Win32 port of Perl.</p>
  93.     <br />
  94.     <hr />
  95.  
  96.     <h2><a name="Certain_functions_don_t_seem_to_">Certain
  97.     functions don't seem to work on Perl for Win32.</a></h2>
  98.  
  99.     <p>There are several functions that are unimplemented in the
  100.     Perl for Win32 system. Primary among these are <code>
  101.     alarm()</code> and <code>fork(),</code> which are used in a few
  102.     Perl modules. Because they're missing in Perl for Win32, you
  103.     can't use those modules. Here is a complete list of
  104.     unimplemented functions:</p>
  105.  
  106.     <dl>
  107.       <dt><strong>Functions for processes and process
  108.       groups</strong></dt>
  109.  
  110.       <dd>
  111.         <p><code>alarm(),</code> <code>fork(),</code> <code>
  112.         getpgrp(),</code> <code>getppid(),</code> <code>
  113.         getpriority(),</code> <code>setpgrp(),</code> <code>
  114.         setpriority()</code></p>
  115.       </dd>
  116.  
  117.       <dt><strong><a name="item_Fetching">Fetching user and group
  118.       info</a></strong></dt>
  119.  
  120.       <dd>
  121.         <p><code>endgrent(),</code> <code>endpwent(),</code> <code>
  122.         getgrent(),</code> <code>getgrgid(),</code> <code>
  123.         getgrnam(),</code> <code>getpwent(),</code> <code>
  124.         getpwnam(),</code> <code>getpwuid(),</code> <code>
  125.         setgrent(),</code> <code>setpwent()</code></p>
  126.       </dd>
  127.  
  128.       <dt><strong><a name="item_System">System V interprocess
  129.       communication functions</a></strong></dt>
  130.  
  131.       <dd>
  132.         <p><code>msgctl(),</code> <code>msgget(),</code> <code>
  133.         msgrcv(),</code> <code>msgsnd(),</code> <code>
  134.         semctl(),</code> <code>semget(),</code> <code>
  135.         semop(),</code> <code>shmctl(),</code> <code>
  136.         shmget(),</code> <code>shmread(),</code> <code>
  137.         shmwrite()</code></p>
  138.       </dd>
  139.  
  140.       <dt><strong>Functions for filehandles, files, or
  141.       directories</strong></dt>
  142.  
  143.       <dd>
  144.         <p><code>link(),</code> <code>symlink(),</code> <code>
  145.         chroot()</code></p>
  146.       </dd>
  147.  
  148.       <dt><strong><a name="item_Input">Input and output
  149.       functions</a></strong></dt>
  150.  
  151.       <dd>
  152.         <p><code>syscall()</code></p>
  153.       </dd>
  154.  
  155.       <dt><strong>Fetching network info</strong></dt>
  156.  
  157.       <dd>
  158.         <p><code>getnetbyname(),</code> <code>
  159.         getnetbyaddr(),</code> <code>getnetent(),</code> <code>
  160.         getprotoent(),</code> <code>getservent(),</code> <code>
  161.         sethostent(),</code> <code>setnetent(),</code> <code>
  162.         setprotoent(),</code> <code>setservent(),</code> <code>
  163.         endhostent(),</code> <code>endnetent(),</code> <code>
  164.         endprotoent(),</code> <code>endservent(),</code> <code>
  165.         socketpair()</code></p>
  166.       </dd>
  167.     </dl>
  168.  
  169.     <p>See the perlport and perlwin32 documentation pages for more
  170.     information on the portability of builtin functions in Perl for
  171.     Win32.</p>
  172.     <br />
  173.     <hr />
  174.  
  175.     <h2><a name="The_exec_function_doesn_t_seem_t">The exec
  176.     function doesn't seem to work under Perl for ISAPI, Perl for
  177.     WebSite, or PerlScript. Why not?</a></h2>
  178.  
  179.     <p>Perl for <font size="-1">ISAPI,</font> Perl for WebSite, and
  180.     PerlScript share a process space with the web server and any
  181.     number of other extensions. As a result, the <code>
  182.     exec()</code> function is unimplemented, because it would cause
  183.     the web server to terminate (the <code>exec()</code> function
  184.     executes a system command and never returns).</p>
  185.     <br />
  186.     <hr />
  187.  
  188.     <h2><a name="What_s_the_difference_between_Pe">What's the
  189.     difference between Perl for Win32 and the old 3xx
  190.     builds?</a></h2>
  191.  
  192.     <p>At one time, Perl on the Win32 platform was found in two
  193.     versions, Gurusamy Sarathy's port, and the ActiveState port.
  194.     The ActiveState port of Perl included such tools as Perl for
  195.     <font size="-1">ISAPI</font> and PerlScript, at the expense of
  196.     exposing Perl's internals in a slightly different fashion than
  197.     standard Perl. Sarathy's port featured a high degree of
  198.     compatibility with standard Perl, which enabled users of
  199.     Sarathy's port to use many modules that were not compatible
  200.     with ActiveState Perl.</p>
  201.  
  202.     <p>The oneperl effort brought both ports of Perl together, and
  203.     Perl for Win32 is the standard perl distribution for the Win32
  204.     system. All modules that can be used on Win32 can be used with
  205.     this port. You no longer have to worry about whose perl the
  206.     module is for. Just grab it, compile it (if needed), and use
  207.     it.</p>
  208.     <br />
  209.     <hr />
  210.  
  211.     <h2><a name="What_s_the_difference_between_ru">What's the
  212.     difference between running Perl for Win32 on Windows NT versus
  213.     running it on Windows 95?</a></h2>
  214.  
  215.     <p>There should be little difference between running Perl on
  216.     the two operating systems. You should watch for the following,
  217.     though:</p>
  218.  
  219.     <ul>
  220.       <li>
  221.         <p>The Win32::NetAdmin, Win32::NetResource, and
  222.         Win32::EventLog modules will not run on Windows 95.</p>
  223.       </li>
  224.  
  225.       <li>
  226.         <p>Some functions that work on Windows <font size="-1">
  227.         NT</font> reportedly do not work or are buggy on Windows
  228.         95. An example is <code>flock().</code></p>
  229.       </li>
  230.  
  231.       <li>
  232.         <p>Finally, many helpful programs that are available on
  233.         Windows <font size="-1">NT</font> are not there on Windows
  234.         95. <code>hostname</code>, for example, is not available on
  235.         Windows 95.</p>
  236.       </li>
  237.     </ul>
  238.  
  239.     <p>If you're worried about using a feature from one or the
  240.     other, check the result of the function Win32::IsWinNT() to see
  241.     what <font size="-1">OS</font> you're running on. See <a href= 
  242.     "perlwin32faq9.html#What_modules_come_with_the_Perl_">What
  243.     modules come with the Perl for Win32 distribution?</a>.</p>
  244.     <br />
  245.     <hr />
  246.  
  247.     <h2><a name="Why_don_t_the_examples_from_the_">Why don't the
  248.     examples from the Camel book work?</a></h2>
  249.  
  250.     <p>The Camel book (aka <em>Programming Perl</em>, Wall et.al.,
  251.     O'Reilly & Associates 1996) was written by <font size="-1">
  252.     UNIX</font> people for, in general, <font size="-1">UNIX</font>
  253.     people.</p>
  254.  
  255.     <p>Some of the examples in the Camel book will work. Some will
  256.     not. If they fail, it's because either the functions used are
  257.     not available, the external tools used are not available, or
  258.     the modules used are not available. Usually, for small scripts,
  259.     it's not to hard to fiddle with them until they come out
  260.     correct (see <a href="#How_do_I_make_a_UNIX_based_scrip">How do
  261.     I make a UNIX-based script work?</a>).</p>
  262.  
  263.     <p>The Camel and Llama books are good learning tools. However,
  264.     one of the things you learn as a Perl for Win32 programmer is
  265.     how to port UNIX-targeted scripts and modules to Perl for
  266.     Win32.</p>
  267.  
  268.     <p>For better examples of using Perl for Win32, you may want to
  269.     look at the Gecko book, ``Learning Perl on Win32 Systems,''
  270.     published by O'Reilly.</p>
  271.     <br />
  272.     <hr />
  273.  
  274.     <h2><a name="Why_don_t_certain_standard_libra">Why don't
  275.     certain standard library modules work?</a></h2>
  276.  
  277.     <p>With Perl for Win32, almost all modules will work with Perl
  278.     for Win32 as long as they can be built to run on Win32. The
  279.     problems that existed with the 3xx versions of Perl for Win32
  280.     no longer exist: modules work on Win32, not just this port or
  281.     that port of Perl for the Win32 platform!</p>
  282.  
  283.     <p>If a module doesn't work, it may be because the functions it
  284.     uses are specific to <font size="-1">UNIX</font> and won't work
  285.     on Win32, or specific to <font size="-1">NT</font> and won't
  286.     work on Windows 95 or Windows 98.</p>
  287.     <br />
  288.     <hr />
  289.  
  290.     <h2><a name="How_do_I_make_a_UNIX_based_scrip">How do I make a
  291.     UNIX-based script work?</a></h2>
  292.  
  293.     <p>First, make extra-super sure that you are using the script
  294.     or module in the way it was intended. Many of us are quick to
  295.     blame the module, the operating system, or the interpreter
  296.     when, in reality, it is our own code that isn't working
  297.     right.</p>
  298.  
  299.     <p>If you're sure that it's not a problem in your code, the
  300.     best way to make a UNIX-based script work is to desk-check it
  301.     before running it. Look for some of the following things:</p>
  302.  
  303.     <ul>
  304.       <li>
  305.         <p>Calls to functions unimplemented in Perl for Win32. For
  306.         a list, see <a href="#Certain_functions_don_t_seem_to_">
  307.         Certain functions don't seem to work on Perl for
  308.         Win32.</a>.</p>
  309.       </li>
  310.  
  311.       <li>
  312.         <p>Calls to standard library modules or <font size="-1">
  313.         CPAN</font> modules that aren't available on Perl for
  314.         Win32, or that don't work.</p>
  315.       </li>
  316.  
  317.       <li>
  318.         <p><code>system()</code> or backtick (``) calls to system
  319.         tools that aren't available on Perl for Win32.</p>
  320.       </li>
  321.  
  322.       <li>
  323.         <p>Reading and writing files that may be binary. See <a
  324.         href="perlwin32faq8.html#Reading_from_and_writing_to_file">
  325.         Reading from and writing to files mysteriously fails.
  326.         What's wrong?</a>.</p>
  327.       </li>
  328.  
  329.       <li>
  330.         <p>File-system dependent path names and path name parsing.
  331.         Watch for hard-coded <font size="-1">UNIX</font> paths like
  332.         <em>/usr/lib</em>.</p>
  333.       </li>
  334.  
  335.       <li>
  336.         <p>The module or script may require a specific version of
  337.         Perl or another module. Watch out for things like <code>
  338.         require 5.003;</code> or <code>require Sockets 1.03;</code>
  339.         Check to see if the script or module really requires the
  340.         new version.</p>
  341.       </li>
  342.     </ul>
  343.  
  344.     <p>Of course, it should go without saying that for everything
  345.     you take out you'll have to put in a work-around.</p>
  346.  
  347.     <p>Once you've worked around <font size="-1">UNIX</font>
  348.     dependencies in the script or module, try running it through
  349.     the debugger to see if what you did helps. If the script or
  350.     module comes with a <em>.t</em> test file, try using that to
  351.     test your changed version.</p>
  352.  
  353.     <p>If you do make a change to a UNIX-based script or module,
  354.     please let the author know. Sometimes the author will be
  355.     gracious enough to make changes that will let the program run
  356.     on Perl for Win32. If the author won't change the program, ask
  357.     if you can make the altered version available to other
  358.     users.</p>
  359.     <br />
  360.     <hr />
  361.  
  362.     <h2><a name="How_does_the_chmod_function_work">How does the
  363.     chmod function work on Win32 platforms?</a></h2>
  364.  
  365.     <p><code>chmod()</code> is supported in Perl for Win32.
  366.     However, it can only be used for setting "owner" read/write
  367.     access. (The "group" and "other" bits are ignored.)</p>
  368.  
  369.     <p>UNIX-style security for files is not applicable to files on
  370.     Win32 systems. Win32 systems inherit from <font size="-1">
  371.     DOS</font> four possible file attributes: archived <font size= 
  372.     "-1">(A),</font> read-only <font size="-1">(R),</font> hidden
  373.     <font size="-1">(H),</font> and system <font size="-1">
  374.     (S).</font> These can be checked and set with the
  375.     Win32::File::Get/SetAttributes().</p>
  376.  
  377.     <p>Windows <font size="-1">NT</font> systems using <font size= 
  378.     "-1">NTFS</font> can also have more specific permissions
  379.     granted on individual files to users and groups. For builds 300
  380.     and above, and the Perl Resource Kit for Win32, you can use the
  381.     Win32::FileSecurity module to maintain file permissions.</p>
  382.     <br />
  383.     <hr />
  384.  
  385.     <h2><a name="4DOS_doesn_t_recognize_on_the">4DOS doesn't
  386.     recognize \" on the command line.</a></h2>
  387.  
  388.     <p> <font size="-1">4DOS</font> doesn't recognize the escaped
  389.     quote on the command line, because all double-quote characters
  390.     are seen as delimiters for command line parameters. This is one
  391.     of the few points (if not the only one) where <font size="-1">
  392.     4DOS</font> doesn't quite match up to <em>COMMAND.COM</em>.</p>
  393.  
  394.     <p>To get around this, you can enter</p>
  395.     <br />
  396. <pre>
  397.     perl -e "print \"Hello, World\n\""
  398. </pre>
  399.  
  400.     <p>as</p>
  401.     <br />
  402. <pre>
  403.     perl -e "print qq(Hello, World\n)"
  404. </pre>
  405.  
  406.     <p>using Perl's alternative quoting mechanism. The alternative
  407.     quotes are <code>qq()</code> for double quotes, <code>
  408.     q()</code> for single quotes, <code>qx()</code> for backquotes,
  409.     and <code>qw()</code> for list quotes. The parentheses can be
  410.     substituted for just about anything (like + or | or {} or
  411.     <> or #), but that looks weird.</p>
  412.     <br />
  413.     <hr />
  414.  
  415.     <h2><a name="STDIN_and_STDOUT_and_Piping_don">STDIN and STDOUT,
  416.     and Piping don't always work on NT.</a></h2>
  417.  
  418.     <p>You may get unexpected results when you try to redirect the
  419.     output of files that use Windows NT's file association feature.
  420.     You can use pl2exe or pl2bat to convert a Perl script to an
  421.     executable or a batch file. This should solve any problems you
  422.     may have with redirection.</p>
  423.     <br />
  424.     <hr />
  425.  
  426.     <h2><a name="#Signal_Handling">Why doesn't signal handling work
  427.     on Windows?</a></h2>
  428.  
  429.     <p>Signals are unsupported by the Win32 API. The C Runtime
  430.     provides crude support for signals, but there are serious
  431.     caveats, such as inability to die() or exit() from a signal
  432.     handler. Perl itself does not guarantee that signal handlers
  433.     will not interrupt critical operations such as memory
  434.     allocation, which means signal invocation may throw perl
  435.     internals into disarray. For these reasons, signals are
  436.     unsupported at this time.</p>
  437.     <br />
  438.     <hr />
  439.  
  440.     <h1><a name="AUTHOR_AND_COPYRIGHT">AUTHOR AND
  441.     COPYRIGHT</a></h1>
  442.  
  443.     <p>This <font size="-1">FAQ</font> was originally assembled and
  444.     maintained by Evangelo Prodromou. <a href= 
  445.     "mailto:evangelo@endcontsw.com">evangelo@endcontsw.com.</a> It
  446.     has been revised and updated by Brian Jepson of O'Reilly and
  447.     Associates, and David Grove and David Dmytryshyn of
  448.     ActiveState.</p>
  449.  
  450.     <p>This <font size="-1">FAQ</font> is in the public domain. If
  451.     you use it, however, please ensure that you give credit to the
  452.     original authors.</p>
  453.  
  454.     <p><!-- beginning of leaf footer--></p>
  455.  
  456.     <table width="100%">
  457.       <tr>
  458.         <td bgcolor="000000" width="70" height="31"><a href= 
  459.         "http://www.activestate.com/"><img src="ASbutton.gif" alt= 
  460.         "ActiveState Home Page" border="0" width="68" height=
  461.         "30" /></a></td>
  462.  
  463.         <td width="10"> </td>
  464.  
  465.         <td valign="middle" bgcolor="#cc0066"><font face=
  466.         "sans-serif" size="+1" color="#ff99cc">   
  467.         Win32 FAQ</font></td>
  468.       </tr>
  469.     </table>
  470.     <!-- end  of leaf footer-->
  471.   </body>
  472. </html>
  473.  
  474.