home *** CD-ROM | disk | FTP | other *** search
/ Chip: Windows 2000 Professional Resource Kit / W2KPRK.iso / apps / perl / ActivePerl.exe / data.z / perlwin32faq4.html < prev    next >
Encoding:
Extensible Markup Language  |  1999-10-15  |  37.1 KB  |  1,052 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>perlwin32faq4 - Windows NT and Windows 95</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="#Where_can_I_get_Windows_NT_infor">Where can
  40.           I get Windows NT information?</a></li>
  41.  
  42.           <li><a href="#Where_can_I_get_Windows_95_infor">Where can
  43.           I get Windows 95/98 information?</a></li>
  44.  
  45.           <li><a href="#What_s_the_equivalent_of_the_she">What's
  46.           the equivalent of the shebang ("#!") syntax for
  47.           Win32?</a></li>
  48.  
  49.           <li><a href="#What_s_the_equivalent_of_chmod_f">What's
  50.           the equivalent of chmod for Win32?</a></li>
  51.  
  52.           <li><a href="#How_do_I_send_email_from_Perl_fo">How do I
  53.           send email from Perl for Win32?</a></li>
  54.  
  55.           <li><a href="#How_do_I_schedule_jobs_on_Win32_">How do I
  56.           schedule jobs on Win32 platforms?</a></li>
  57.  
  58.           <li><a href="#Where_can_I_find_Win32_ports_of_">Where can
  59.           I find Win32 ports of UNIX tools?</a></li>
  60.  
  61.           <li><a href="#What_is_a_Windows_NT_service_">What is a
  62.           Windows NT service?</a></li>
  63.  
  64.           <li><a href="#How_do_I_run_a_Perl_script_as">How do I run
  65.           a Perl script as a Windows NT service?</a></li>
  66.  
  67.           <li><a href="#How_do_I_set_permissions_on_a_fi">How do I
  68.           set permissions on a file?</a></li>
  69.  
  70.           <li><a href="#How_do_I_associate_Perl_scripts_">How do I
  71.           associate Perl scripts with perl?</a></li>
  72.  
  73.           <li><a href="#perl_dash_e">Why doesn't "perl -e"
  74.           work?</a></li>
  75.  
  76.           <li><a href="#What_editors_are_available_for_Windows">
  77.           What editors are available for Windows?</a></li>
  78.         </ul>
  79.       </li>
  80.  
  81.       <li><a href="#AUTHOR_AND_COPYRIGHT">AUTHOR AND
  82.       COPYRIGHT</a></li>
  83.     </ul>
  84.     <!-- INDEX END -->
  85.     <hr />
  86.     <br />
  87.  
  88.     <h1><a name="NAME">NAME</a></h1>
  89.  
  90.     <p>perlwin32faq4 - Windows <font size="-1">NT</font> and
  91.     Windows 95</p>
  92.     <br />
  93.     <hr />
  94.  
  95.     <h1><a name="DESCRIPTION">DESCRIPTION</a></h1>
  96.  
  97.     <p>Useful information about Windows <font size="-1">NT</font>
  98.     and Windows 95 for Perl developers</p>
  99.     <br />
  100.     <hr />
  101.  
  102.     <h2><a name="Where_can_I_get_Windows_NT_infor">Where can I get
  103.     Windows NT information?</a></h2>
  104.  
  105.     <p> <font size="-1">A</font> good starting place is the printed
  106.     documentation that came with Windows <font size="-1">NT</font>
  107.     and on the Windows <font size="-1">NT</font> <font size="-1">
  108.     CD</font> in the <em>support\books</em> directory. Windows Help
  109.     files are also available.</p>
  110.  
  111.     <p>You can get some in-depth information on Windows <font size= 
  112.     "-1">NT</font> from the Windows <font size="-1">NT</font>
  113.     Resource Kit, available at bookstores and from Microsoft.
  114.     Microsoft TechNet is also a valuable resource.</p>
  115.  
  116.     <p>World Wide Web support for Windows <font size="-1">NT</font>
  117.     Server is at:</p>
  118.     <br />
  119. <pre>
  120.     <a href=
  121. "http://www.microsoft.com/ntserver/">http://www.microsoft.com/ntserver/</a>
  122. </pre>
  123.  
  124.     <p>Support for Windows <font size="-1">NT</font> Workstation is
  125.     at:</p>
  126.     <br />
  127. <pre>
  128.     <a href=
  129. "http://www.microsoft.com/ntworkstation/">http://www.microsoft.com/ntworkstation/</a>
  130. </pre>
  131.     <br />
  132.     <hr />
  133.  
  134.     <h2><a name="Where_can_I_get_Windows_95_infor">Where can I get
  135.     Windows 95/98 information?</a></h2>
  136.  
  137.     <p>Printed documentation comes with Windows 95/98, as well as
  138.     some documentation on the <font size="-1">CD-ROM.</font> Help
  139.     files are available from the Start menu.</p>
  140.  
  141.     <p>The Windows 95 Resource Kit contains in-depth information on
  142.     Windows 95. It's available at bookstores and software
  143.     stores.</p>
  144.  
  145.     <p>World Wide Web support for Windows 95/98 is at:</p>
  146.     <br />
  147. <pre>
  148.     <a href=
  149. "http://www.microsoft.com/windows95/">http://www.microsoft.com/windows95/</a>
  150. </pre>
  151. <pre>
  152.     <a href=
  153. "http://www.microsoft.com/windows98/">http://www.microsoft.com/windows98/</a>
  154. </pre>
  155.     <br />
  156.     <hr />
  157.  
  158.     <h2><a name="What_s_the_equivalent_of_the_she">What's the
  159.     equivalent of the shebang ("#!") syntax for Win32?</a></h2>
  160.  
  161.     <p>Unfortunately, Win32 platforms don't provide the shebang
  162.     syntax, or anything like it. You can try one of the two
  163.     following methods to run a script from the command line. If all
  164.     else fails, you can always just call the perl interpreter
  165.     directly, as in <code>perl myscript.pl</code>.</p>
  166.  
  167.     <p> Although Win32 systems themselves don't use the shebang,
  168.     the Apache webserver does. If you are using the Apache
  169.     webserver on your Win32 system you should put the shebang line
  170.     at the top of your CGI scripts.</p>
  171.  
  172.     <p>Your shebang line should look something like:</p>
  173. <pre>
  174.    #!perl
  175. </pre>
  176.  
  177.     <p>For Windows <font size="-1">NT</font> 4.0, the coolest
  178.     method is to use associated file types (see <a href= 
  179.     "#How_do_I_associate_Perl_scripts_">How do I associate Perl
  180.     scripts with perl?</a>). If you've associated Perl scripts with
  181.     the <em>.pl</em> extension, you can just type the name of your
  182.     file at the command line and Windows <font size="-1">NT</font>
  183.     will launch <em>perl.exe</em> for you. If you change the <code>
  184.     PATHEXT</code> environment variable to include <em>.pl</em>
  185.     files, like this:</p>
  186.     <br />
  187. <pre>
  188.     SET PATHEXT=.pl;%PATHEXT%
  189. </pre>
  190.  
  191.     <p>you can just type the file name without an extension, and
  192.     Windows <font size="-1">NT</font> will find the first <em>
  193.     .pl</em> file in your path with that name. You may want to set
  194.     <code>PATHEXT</code> in the System control panel rather than on
  195.     the command line. Otherwise, you'll have to re-enter it each
  196.     time the command prompt window closes.</p>
  197.  
  198.     <p>Given this setup, you can have a Perl script called <em>
  199.     cat.pl</em> that looks like this:</p>
  200.     <br />
  201. <pre>
  202.     while ( <> ) {
  203.         print;
  204.     }
  205. </pre>
  206.  
  207.     <p>and you can invoke it on the command line like this:</p>
  208.     <br />
  209. <pre>
  210.     cat myfile.txt
  211. </pre>
  212.  
  213.     <p>However, you can't invoke it with <font size="-1">I/O</font>
  214.     redirection, like this:</p>
  215.     <br />
  216. <pre>
  217.     cat < myfile.txt
  218.     cat myfile.txt | more
  219. </pre>
  220.  
  221.     <p>although it looks like you should be able to (this is a
  222.     limitation of Windows <font size="-1">NT).</font> Your script
  223.     can be in your path or you can provide a path to the file.</p>
  224.  
  225.     <p>Note that the file association method does not work for
  226.     Windows 95, nor does it work with Windows <font size="-1">
  227.     NT</font> if you have command extensions disabled. You can,
  228.     however, still start the Perl script from an Explorer window if
  229.     the extension is associated with perl.</p>
  230.  
  231.     <p>Another option is to use the pl2bat utility distributed with
  232.     Perl for Win32 to convert your Perl script into a batch file.
  233.     What this does is tag some Win32 batch language to the front of
  234.     your script so that the system calls the perl interpreter on
  235.     the file. It's quite a clever piece of batch coding,
  236.     actually.</p>
  237.  
  238.     <p>If you call the pl2bat utility on your Perl script <em>
  239.     helloworld.pl</em>, like this:</p>
  240.     <br />
  241. <pre>
  242.     C:\> pl2bat helloworld.pl
  243. </pre>
  244.  
  245.     <p>it will produce a batch file, <em>helloworld.bat</em>. You
  246.     can then invoke the script just like this:</p>
  247.     <br />
  248. <pre>
  249.     C:\> helloworld
  250.     Hello, World!
  251. </pre>
  252.  
  253.     <p>You can pass command line parameters, as well. Your script
  254.     can be in your <code>PATH</code>, or in another directory, and
  255.     the pl2bat code will usually find it and execute it correctly.
  256.     The big advantage of this over file associations is that <font
  257.     size="-1">I/O</font> redirection will work correctly.</p>
  258.  
  259.     <p>pl2bat has a number of useful command line options to affect
  260.     how the wrapping is done, what command line switches to pass to
  261.     perl, etc. Running <code>perldoc pl2bat</code> at the command
  262.     line will show a full description of these options.</p>
  263.  
  264.     <p>The pl2exe utility is similar to pl2bat, but it puts an
  265.     executable header on your perl script, producing an <font size= 
  266.     "-1">EXE</font> file that cannot be directly edited.
  267.     Redirection also works correctly under scripts that have been
  268.     run through pl2exe.</p>
  269.     <br />
  270.     <hr />
  271.  
  272.     <h2><a name="What_s_the_equivalent_of_chmod_f">What's the
  273.     equivalent of chmod for Win32?</a></h2>
  274.  
  275.     <p>There is no direct equivalent of the chmod tool on Win32
  276.     systems. For file attributes, you can use the <em>ATTRIB</em>
  277.     command line tool (type <code>HELP ATTRIB</code> at the command
  278.     line for details). For more complex permissions, see <a href= 
  279.     "#How_do_I_set_permissions_on_a_fi">How do I set permissions on
  280.     a file?</a>.</p>
  281.  
  282.     <p>For information on the <code>chmod()</code> function, see <a
  283.     href="perlwin32faq5.html#How_does_the_chmod_function_work">How
  284.     does the chmod function work on Win32 platforms?</a>.</p>
  285.     <br />
  286.     <hr />
  287.  
  288.     <h2><a name="How_do_I_send_email_from_Perl_fo">How do I send
  289.     email from Perl for Win32?</a></h2>
  290.  
  291.     <p>You may come across scripts that send email with an external
  292.     mail program, as in:</p>
  293.     <br />
  294. <pre>
  295.    
  296.         open(MAIL, '| /usr/lib/sendmail user@there.com') or "die";
  297.         print MAIL <<EOF;
  298.         To: user@there.com
  299.         From: user@here.com
  300.         Hello, World!
  301.         EOF
  302. </pre>
  303.  
  304.     <p>These sort of scripts generally cause people to ask, ``is
  305.     there a sendmail equivalent on Windows?'' If you need to send
  306.     email from a Perl script, there is no need to use an external
  307.     program like sendmail. The libnet bundle includes <code>
  308.     Net::SMTP</code>, a module that can be used to send mail. Here
  309.     is an example:</p>
  310.     <br />
  311. <pre>
  312.  
  313.         use Net::SMTP;
  314.  
  315.         $smtp = Net::SMTP->new('here.com'); # connect to an SMTP server
  316.         $smtp->mail( 'user@here.com' );     # use the sender's address here
  317.         $smtp->to('user@there.com');        # recipient's address
  318.         $smtp->data();                      # Start the mail
  319.  
  320.         # Send the header.
  321.         $smtp->datasend("To: user@there.com\n");
  322.         $smtp->datasend("From: user@here.com\n");
  323.         $smtp->datasend("\n");
  324.  
  325.         # Send the body.
  326.         $smtp->datasend("Hello, World!\n");
  327.         $smtp->dataend();                   # Finish sending the mail
  328.         $smtp->quit;                        # Close the SMTP connection
  329. </pre>
  330.  
  331.     <p> Another alternative is Mail::Sender, which can be used like
  332.     so:</p>
  333.     <br />
  334. <pre>
  335.         use Mail::Sender;
  336.      
  337.         $sender = new Mail::Sender {smtp => 'mail.yourdomain.com', from => 'your@address.com'};
  338.         $sender->MailFile({to => 'some@address.com', subject => 'Here is the file', 
  339.                          msg => "I'm sending you the list you wanted.", 
  340.                            file => 'filename.txt'});
  341. </pre>
  342.  
  343.     <p>Or Mail::Sendmail, which can be used like this:</p>
  344.     <br />
  345. <pre>
  346.         use Mail::Sendmail;
  347.  
  348.         %mail = ( To      => 'you@there.com',
  349.                   From    => 'me@here.com',
  350.                   Message => "This is a minimalistic message"
  351.                  );
  352.  
  353.         if (sendmail %mail) { print "Mail sent OK.\n" }
  354.         else { print "Error sending mail: $Mail::Sendmail::error \n" }
  355. </pre>
  356.     <font size="-1">A</font> Perl script for sending mail without
  357.     using an external program is also available on Robin
  358.     Chatterjee's Perl for Win32 page (see <a href= 
  359.     "perlwin32faq3.html#Are_there_information_sources_av">Are there
  360.     information sources available on Perl for Win32 on the World
  361.     Wide Web?</a>). 
  362.  
  363.     <p>If you really need a sendmail equivalent for Windows,
  364.     several such equivalents exist:</p>
  365.  
  366.     <dl>
  367.       <dt><strong><a name="item_Blat">Blat</a></strong></dt>
  368.  
  369.       <dd>
  370.         <p>Blat is a public domain program for sending email from
  371.         the Windows <font size="-1">NT</font> command-line.
  372.         Although it is reputed to work under Windows 95, the Blat
  373.         authors have not tested it under Windows 95. The Blat home
  374.         page is located at <a href= 
  375.         "http://gepasi.dbs.aber.ac.uk/softw/Blat.html">
  376.         http://gepasi.dbs.aber.ac.uk/softw/Blat.html</a></p>
  377.       </dd>
  378.  
  379.       <dt><strong><a name="item_sendmail">
  380.       sendmail</a></strong></dt>
  381.  
  382.       <dd>
  383.         <p>Microsoft has a port of sendmail available on their
  384.         <font size="-1">FTP</font> site at <a href= 
  385.         "ftp://ftp.microsoft.com/developr/drg/unix-to-windows/ports/sendmail/">
  386.         ftp://ftp.microsoft.com/developr/drg/unix-to-windows/ports/sendmail/</a></p>
  387.  
  388.         <p> <font size="-1">A</font> commercial sendmail product is
  389.         available from MetaInfo, Inc. An evaluation version is
  390.         available at <a href="http://www.metainfo.com/">
  391.         http://www.metainfo.com/</a></p>
  392.       </dd>
  393.  
  394.       <dt><strong><a name="item_wrmail">wrmail</a></strong></dt>
  395.  
  396.       <dd>
  397.         <p>Another commercial mail product is wrmail, part of the
  398.         slmail product from Seattle Labs. <font size="-1">A</font>
  399.         free version is available at <a href= 
  400.         "http://www.seattlelab.com/">
  401.         http://www.seattlelab.com/</a></p>
  402.       </dd>
  403.     </dl>
  404.     <br />
  405.     <hr />
  406.  
  407.     <h2><a name="How_do_I_schedule_jobs_on_Win32_">How do I
  408.     schedule jobs on Win32 platforms?</a></h2>
  409.  
  410.     <p> The <font size="-1">UNIX</font> cron utility doesn't exist
  411.     on Win32 platforms.</p>
  412.  
  413.     <p>For Windows <font size="-1">NT,</font> a scheduling tool
  414.     called <code>AT</code> is available. Unlike the <font size=
  415.     "-1">UNIX</font> cron utility, <code>AT</code> doesn't store
  416.     its schedule in a flat file, but is configured using
  417.     command-line arguments. Note the AT command seems to be very
  418.     picky about syntax. Here is one example:</p>
  419. <pre>
  420.         at 23:37 /interactive /every:M,T,W,Th,F,S,Su cmd /c "c:\perl\bin\perl.exe c:\test.pl"
  421. </pre>
  422.  
  423.     <p>If you don't like the command-line version of <code>
  424.     AT</code>, there's a <font size="-1">GUI</font> version, WinAT,
  425.     which is available with the Windows <font size="-1">NT</font>
  426.     Resource Kit. The "Schedule" service must be running when your
  427.     job is supposed to happen.</p>
  428.  
  429.     <p>Note that you may have problems when running AT or WinAT if
  430.     the scheduled program or script requires any special rights or
  431.     permissions other than those held by "System" (ie, if it is
  432.     working across computers or NT domains). This is because NT
  433.     does not properly allow you to run preinstalled NT services,
  434.     such as the "Schedule" service as a user with network
  435.     priveleges. It may <i>look</i> like you can set the scheduler
  436.     to login as a user with network priveledges, but the service
  437.     just does not recognize that user's right's and permissions and
  438.     the System userid has only local permissions.</p>
  439.  
  440.     <p> An all-Perl cron-like solution exists at <a href= 
  441.     "http://www.megadodo.demon.co.uk/perl/">
  442.     http://www.megadodo.demon.co.uk/perl/</a> which uses a familiar
  443.     Unix-like crontab file. This script can be ran as an NT Service
  444.     (see <a href="#What_is_a_Windows_NT_service_">How do I set up a
  445.     Perl script as an NT Service?</a>). When you create your own NT
  446.     service, NT lets you set the useid/password pair, and these
  447.     services do recognize that userid's rights and permissions.
  448.     Hence, the scheduled program or script will have the necessary
  449.     rights.</p>
  450.  
  451.     <p>There are a few commercial cron-like schedulers. NTcrond, is
  452.     available from ifdef software: <a href="http://www.ifdef.com/">
  453.     http://www.ifdef.com/</a> and AutoTask2000 is available from <a
  454.     href="http://www.cypressnet.com/">
  455.     http://www.cypressnet.com/</a>. These programs <i>should</i>
  456.     recognize the rights and priveleges of the userid you set their
  457.     service to run under to enable the scheduled program or script
  458.     to have the necessary rights.</p>
  459.  
  460.     <p>For Windows 95, there's a System Agent available with the
  461.     Microsoft Plus! Pack. Also, there are several shareware
  462.     scheduling utilities, notably LaunchPad and Metz Scheduler.
  463.     These can be found on a good shareware search engine, such as
  464.     <a href="http://www.shareware.com/">
  465.     http://www.shareware.com/</a>. There is also an optional "Task
  466.     Scheduler" component with IE4.01 and Windows 98.</p>
  467.  
  468.     <p>Because scheduled jobs on Windows <font size="-1">NT</font>
  469.     run as a service (see <a href="#What_is_a_Windows_NT_service_">
  470.     What is a Windows NT service?</a>), you need to take special
  471.     steps to make sure that files and environment variables are
  472.     available to your script.</p>
  473.  
  474.     <p>In some instances, Perl's internal <code>sleep</code>
  475.     function might be an appropriate means of scheduling. For
  476.     example:</p>
  477. <pre>
  478.         $seconds = 180;
  479.         sub action;
  480.         while(1) {
  481.                 &action;
  482.                 sleep($seconds);
  483.         }
  484. </pre>
  485.     <br />
  486.     <hr />
  487.  
  488.     <h2><a name="Where_can_I_find_Win32_ports_of_">Where can I find
  489.     Win32 ports of UNIX tools?</a></h2>
  490.  
  491.     <p>You might want to take a look at the help file for Windows
  492.     <font size="-1">NT</font> and Windows 95 commands to see if
  493.     there's a rough equivalent distributed with your Win32
  494.     platform. If not, try one of these URLs:</p>
  495.  
  496.     <ul>
  497.       <li>
  498.         <p>GNU-Win32 - a Win32 port of many <font size="-1">
  499.         GNU</font> tools, as well as a complete development
  500.         environment. <a href=
  501.         "http://www.cygnus.com/misc/gnu-win32/">
  502.         http://www.cygnus.com/misc/gnu-win32/</a></p>
  503.       </li>
  504.  
  505.       <li>
  506.         <p>Virtually Un*x! - various ports of <font size="-1">
  507.         UNIX</font> programs for Win32. <a href= 
  508.         "http://www.itribe.net/virtunix/">
  509.         http://www.itribe.net/virtunix</a></p>
  510.       </li>
  511.     </ul>
  512.  
  513.     <p>There are also several UNIX-like tools available in the
  514.     Windows <font size="-1">NT</font> Resource Kit. Also, there are
  515.     several UNIX-to-Win32 commercial packages available, including
  516.     the <font size="-1">MKS</font> Toolkit from Mortice Kerns
  517.     Systems, Inc.: <a href="http://www.mks.com/">
  518.     http://www.mks.com/</a> and Interix from Softway Systems: <a
  519.     href="http://www.interix.com/">http://www.interix.com/</a> (the
  520.     product formerly known as OpenNT).</p>
  521.  
  522.     <p>You can also check into the Perl Power Tools, being
  523.     developed under the UNIX Reconstruction Project. Here you can
  524.     find UNIX tools that are being reimplemented into all Perl. You
  525.     can see the latest at <a href="http://language.perl.com/ppt/">
  526.     http://language.perl.com/ppt/</a></p>
  527.     <br />
  528.     <hr />
  529.  
  530.     <h2><a name="What_is_a_Windows_NT_service_">What is a Windows
  531.     NT service?</a></h2>
  532.  
  533.     <p>On Windows <font size="-1">NT,</font> a service is a special
  534.     kind of executable program that runs in the background.
  535.     Services are used for programs that are constantly working,
  536.     such as network protocols or database servers. Most <font size= 
  537.     "-1">WWW</font> servers on Windows <font size="-1">NT</font>
  538.     are implemented as services.</p>
  539.  
  540.     <p> <font size="-1">A</font> service is different from other
  541.     programs in several ways:</p>
  542.  
  543.     <ul>
  544.       <li>
  545.         <p>Services aren't run interactively, although the <code>
  546.         NET START</code> and <code>NET STOP</code> commands can be
  547.         used to start or stop a server. The Services control panel
  548.         is used to start, stop, or pause a service.</p>
  549.       </li>
  550.  
  551.       <li>
  552.         <p>Services don't act with the authority of the logged-in
  553.         user. That means that services can't see user environment
  554.         variables or read files that are readable only by the
  555.         logged-in user. You can set the account that a service uses
  556.         in the Services control panel.</p>
  557.       </li>
  558.  
  559.       <li>
  560.         <p>Services run even when no one is logged in to the
  561.         machine.</p>
  562.       </li>
  563.     </ul>
  564.  
  565.     <p>The most important thing to remember is that you have to
  566.     take special steps to make resources available to services. In
  567.     general, you need to make files available to the Everyone
  568.     group, and you have to have environment variables (like <code>
  569.     PATH</code>) be system environment variables.</p>
  570.     <br />
  571.     <hr />
  572.  
  573.     <h2><a name="How_do_I_run_a_Perl_script_as">How do I run a Perl
  574.     script as a Windows NT Service?</a></h2>
  575.  
  576.     <p>You can run your Perl scripts as Windows NT Services via a
  577.     program called srvany.exe, which comes with the Windows NT
  578.     Resource Kit. Once srvany.exe is installed, read the srvany.wri
  579.     file which should be with it. This document will explain how to
  580.     set up registry entries for your new service.</p>
  581.  
  582.     <p>After you are set up, to run your script as a service
  583.     do:</p>
  584.     <br />
  585. <pre>
  586.     x:>srvany perl script.pl
  587. </pre>
  588.     <br />
  589.     <hr />
  590.  
  591.     <h2><a name="How_do_I_set_permissions_on_a_fi">How do I set
  592.     permissions on a file?</a></h2>
  593.  
  594.     <p>Win32 platforms don't have the same mechanisms for setting
  595.     permissions on files as <font size="-1">UNIX</font> does. For
  596.     files on <font size="-1">FAT</font> partitions (which means all
  597.     files in Windows 95), you don't have to set permissions
  598.     explicitly on a file. All files are available to all users.</p>
  599.  
  600.     <p>For files on an <font size="-1">NTFS</font> partition on
  601.     Windows <font size="-1">NT,</font> you can set the security
  602.     permissions on a file using the Explorer and the properties
  603.     sheet of the file. Right-click the file in Explorer, and choose
  604.     Properties from the drop-down menu. Select the Security tab,
  605.     and click Permissions to set the Permissions on the file. Click
  606.     Help for more information.</p>
  607.  
  608.     <p> <font size="-1">A</font> command-line program, <code>
  609.     CACLS</code>, will also change the permissions on a file. For
  610.     more details, type <code>HELP CACLS</code> on the command
  611.     line.</p>
  612.  
  613.     <p>Windows 95/98 machines that are administered using Novell
  614.     can have accounts and permissions similiar to <font size="-1">
  615.     NT.</font> However, these permissions must be set up by the
  616.     Novell administrator.</p>
  617.     <br />
  618.     <hr />
  619.  
  620.     <h2><a name="How_do_I_associate_Perl_scripts_">How do I
  621.     associate Perl scripts with perl?</a></h2>
  622.  
  623.     <p>On Windows systems, association is the process of specifying
  624.     which programs should be used for which kind of files. Files
  625.     are grouped into file types, such as <font size="-1">
  626.     JPEG</font> files or Perl scripts. The file type of a file is
  627.     identified by its file name extension (all the letters after
  628.     the last ``.'' in the file name).</p>
  629.  
  630.     <p>So, for example, we can say that there's a type of file
  631.     called a text file, which has the file extension <em>.txt</em>,
  632.     and which is handled by the Notepad program.</p>
  633.  
  634.     <p>Usually, Perl for Win32 programmers create a file type like
  635.     Perl Script and associate the extension <em>.pl</em> with that
  636.     type. We specify that the perl interpreter binary, <em>
  637.     perl.exe</em>, is responsible for that file type. Several Web
  638.     servers require that you associate your scripts with <em>
  639.     perl.exe</em> before the script can be run.</p>
  640.  
  641.     <p>On Windows 95 and Windows <font size="-1">NT</font> 4.0, you
  642.     can create a new file type and associate the perl interpreter
  643.     with it as follows:</p>
  644.  
  645.     <ol>
  646.       <li>
  647.         <strong><a name="item_"></a></strong> 
  648.  
  649.         <p>Open the My Computer icon on the Desktop. The My
  650.         Computer window should appear.</p>
  651.       </li>
  652.  
  653.       <li>
  654.          
  655.  
  656.         <p>From the View menu in the My Computer window, choose
  657.         Options. The Options dialog box appears.</p>
  658.       </li>
  659.  
  660.       <li>
  661.          
  662.  
  663.         <p>In the Options dialog box, select the File Types
  664.         tab.</p>
  665.       </li>
  666.  
  667.       <li>
  668.          
  669.  
  670.         <p>Click the New Type button. The Add New File Type dialog
  671.         box appears.</p>
  672.       </li>
  673.  
  674.       <li>
  675.          
  676.  
  677.         <p>In the ``Description of type'' box, type ``Perl
  678.         Script''.</p>
  679.       </li>
  680.  
  681.       <li>
  682.          
  683.  
  684.         <p>In the ``Associated extension'' box, type ``.pl''.</p>
  685.       </li>
  686.  
  687.       <li>
  688.          
  689.  
  690.         <p>Leave the Content Type <font size="-1">(MIME)</font> box
  691.         blank.</p>
  692.       </li>
  693.  
  694.       <li>
  695.          
  696.  
  697.         <p>Click the New button beneath the Actions list. The New
  698.         Action dialog box will appear.</p>
  699.       </li>
  700.  
  701.       <li>
  702.          
  703.  
  704.         <p>In the Action box, type ``Open'' (it's important to use
  705.         this name for the action!).</p>
  706.       </li>
  707.  
  708.       <li>
  709.          
  710.  
  711.         <p>In the ``Application used to perform action'' box, type
  712.         <code>[full path to perl]\perl.exe %1 %*</code>, where
  713.         [full path to perl] is the full path to <em>perl.exe</em>
  714.         on your machine. If perl is in your path, you <em>can</em>
  715.         put just <em>perl.exe</em>, but for esoteric reasons it's
  716.         better to put the full path. Also, if the path to your
  717.         interpreter includes spaces (like <em>C:\Program
  718.         Files\perl5</em>) put in the <font size="-1">DOS</font>
  719.         path instead (<em>C:\progra~1\perl5</em>).</p>
  720.       </li>
  721.  
  722.       <li>
  723.          
  724.  
  725.         <p>Click <font size="-1">OK</font> to close the New Action
  726.         dialog box.</p>
  727.       </li>
  728.  
  729.       <li>
  730.          
  731.  
  732.         <p>Click <font size="-1">OK</font> to close the Add New
  733.         File Type dialog box.</p>
  734.       </li>
  735.  
  736.       <li>
  737.          
  738.  
  739.         <p>Click <font size="-1">OK</font> to close the Options
  740.         dialog box.</p>
  741.       </li>
  742.     </ol>
  743.  
  744.     <p>You can test your association by double-clicking on a perl
  745.     script in the Explorer window. If <em>perl.exe</em> starts and
  746.     executes the script, things are <font size="-1">OK.</font></p>
  747.  
  748.     <p>On Windows <font size="-1">NT</font> 4.0, you can avoid all
  749.     the hassle of the above and just type the following from the
  750.     command line:</p>
  751.     <br />
  752. <pre>
  753.     ASSOC .pl=PerlScript
  754.     FTYPE PerlScript=[full path to perl]\perl.exe %1 %*
  755. </pre>
  756.  
  757.     <p>For more information on these commands, type <code>HELP
  758.     FTYPE</code> at the command prompt.</p>
  759.  
  760.     <p>Note that for this to work you have to have command
  761.     extensions enabled. (These are enabled by default; you'd know
  762.     if you'd turned them off.)</p>
  763.     <br />
  764.     <hr />
  765.  
  766.     <h2><a name="perl_dash_e">Why doesn't 'perl -e' work?</a></h2>
  767.     <br />
  768.     <br />
  769.      
  770.  
  771.     <p>It does - it's just that some command shells (for example
  772.     COMMAND.COM, CMD.EXE and 4DOS) don't accept single quotes
  773.     wrapped around command arguments.</p>
  774.  
  775.     <p>The safest way to do perl one-liners is to wrap the
  776.     parameters within "" (double-quotes) the use q() and qq()
  777.     inside the parameters. q() and qq() with put whatever is inside
  778.     them between single-quotes or double-quotes,
  779.     respectively.<br />
  780.     For example:</p>
  781.  
  782.     <blockquote>
  783.       <p><code>perl -e "use LWP::Simple; while(@c = head <>)
  784.       { $c = join qq(\n\t), @c; print qq(Header info:\n\t$c\n);
  785.       }"</code></p>
  786.     </blockquote>
  787.  
  788.     <p><font size="-1">(this was all one line)</font><br />
  789.     Run this from the command line and type in the URL to your
  790.     favorite website, like <a href="http://www.perl.com/">
  791.     http://www.perl.com/</a>...</p>
  792.  
  793.     <p>The <a href="../lib/Pod/perlwin32.html">perlwin32</a> and <a
  794.     href="../lib/Pod/perlrun.html">perlrun</a> POD pages have more
  795.     information on using the command line.</p>
  796.     <br />
  797.     <hr />
  798.  
  799.     <h2><a name="What_editors_are_available_for_Windows">What
  800.     editors are available for Windows?</a></h2>
  801.  
  802.     <p>Windows comes with two editors that are great for editing
  803.     Perl, NotePad and WordPad. But, if you need more features for
  804.     ease of editing, here is a list of free and commercial
  805.     editors:</p>
  806.     <br />
  807.  
  808.     <ul>
  809.       <li>
  810.         <b>BBEdit</b> - <a href="http://www.barebones.com/">
  811.         http://www.barebones.com/</a> 
  812.  
  813.         <ul>
  814.           <li>A Macintosh editor that supports multiple languages
  815.           including Perl. By adding Brad Hanson's BBEdit Plug-Ins
  816.           you can run your Perl scripts right in BBEdit</li>
  817.         </ul>
  818.         <br />
  819.       </li>
  820.  
  821.       <li>
  822.         <b>CodeWright</b> - <a href="http://www.premia.com/">
  823.         http://www.premia.com/</a> 
  824.  
  825.         <ul>
  826.           <li>With Codewright, you choose the compiler, the
  827.           assembler, the version control system--any tools you
  828.           like--and Codewright works with you. Includes Perl
  829.           language support.</li>
  830.         </ul>
  831.         <br />
  832.       </li>
  833.  
  834.       <li>
  835.         <b>ED for Windows</b> - <a href="http://www.getsoft.com/">
  836.         http://www.getsoft.com/</a> 
  837.  
  838.         <ul>
  839.           <li>ED leads the way in intelligent language sensitive
  840.           editing. Supporting both DOS and Windows, ED is as easy
  841.           to use as it is to spell. Up and running straight out of
  842.           the box for the new user but highly configurable, ED fits
  843.           the way YOU want to work. Includes support for Perl
  844.           syntax highlighting.</li>
  845.         </ul>
  846.         <br />
  847.       </li>
  848.  
  849.       <li>
  850.         <b>GNU Emacs for Windows</b> - <a href= 
  851.         "http://www.cs.washington.edu/homes/voelker/ntemacs.html">
  852.         http://www.cs.washington.edu/homes/voelker/ntemacs.html</a>
  853.         
  854.  
  855.         <ul>
  856.           <li>"Emacs is the extensible, customizable,
  857.           self-documenting real-time display editor."</li>
  858.         </ul>
  859.         <br />
  860.       </li>
  861.  
  862.       <li>
  863.         <b>HomeSite</b> - <a href="http://www.allaire.com/">
  864.         http://www.allaire.com</a> 
  865.  
  866.         <ul>
  867.           <li>HomeSite 4.0 is the award-winning HTML editing tool
  868.           that lets you build great Web sites in less time, while
  869.           maintaining Pure HTML. Good editor for ASP, and
  870.           PerlScript.</li>
  871.         </ul>
  872.         <br />
  873.       </li>
  874.  
  875.       <li>
  876.         <b>MultiEdit</b> - <a href="http://www.amcyber.com/">
  877.         http://www.amcyber.com/</a> 
  878.  
  879.         <ul>
  880.           <li>MultiEdit is an multiple language editor. Perl
  881.           language support includes - smart indenting, template
  882.           editing, construct matching, code completion, context
  883.           highlighting, brace/parenthesis alignment and
  884.           line-numbering. Other MulitEdit features include multiple
  885.           file search/replace, HTML and ASP support, web site
  886.           management, integration with several IDEs and debuggers,
  887.           and the ability to compare and sychronize files while
  888.           editing.</li>
  889.         </ul>
  890.         <br />
  891.       </li>
  892.  
  893.       <li>
  894.         <b>NoteTab</b> - <a href="http://www.notetab.com/">
  895.         http://www.notetab.com</a> 
  896.  
  897.         <ul>
  898.           <li>Seamless support for Perl and Gawk scripts (only
  899.           commercial versions).</li>
  900.         </ul>
  901.         <br />
  902.       </li>
  903.  
  904.       <li>
  905.         <b>Perl Builder</b> - <a href= 
  906.         "http://www.solutionsoft.com/perl.htm">
  907.         http://www.solutionsoft.com/perl.htm</a> 
  908.  
  909.         <ul>
  910.           <li>Perl Builder is a complete, integrated development
  911.           environment (IDE) for Perl. Whether you are an
  912.           experienced Perl developer or a non-programmer who needs
  913.           to create Perl CGI scripts, Perl Builder's visual tools
  914.           are guaranteed to dramatically improve your productivity!
  915.           Perl Builder is a 32-bit application and requires Windows
  916.           95 or NT.</li>
  917.         </ul>
  918.         <br />
  919.       </li>
  920.  
  921.       <li>
  922.         <b>Perl Scripting Tool</b> - 
  923.  
  924.         <ul>
  925.           <li>PST was intended as a replacement for Windows'
  926.           Notepad, which until now has been the editor of choice
  927.           for Win32 PERL Programmers. While Notepad is usually
  928.           sufficient there has long been the need for something
  929.           with 'just a little more'. This simple editor is Notepad
  930.           with a few extra options for PERL script authoring,
  931.           including a subroutine library, code wizard, run, debug,
  932.           syntax check, floating toolbox and more. An extremely
  933.           simple and straight-forward PERL GUI.</li>
  934.         </ul>
  935.         <br />
  936.       </li>
  937.  
  938.       <li>
  939.         <b>Programmer's File Editor (PFE)</b> - <a href= 
  940.         "http://www.lancs.ac.uk/people/cpaap/pfe/">
  941.         http://www.lancs.ac.uk/people/cpaap/pfe/</a> 
  942.  
  943.         <ul>
  944.           <li>PFE is a large-capacity, multi-file editor that runs
  945.           on Windows 98, Windows 95, Windows NT 4.0 and Windows
  946.           2000 on Intel-compatible processors, and on Windows 3.1x.
  947.           Although it's primarily oriented towards program
  948.           developers and contains features like the ability to run
  949.           compilers and development applications, it also makes a
  950.           very good general purpose editor for any function at
  951.           all.</li>
  952.         </ul>
  953.         <br />
  954.       </li>
  955.  
  956.       <li>
  957.         <b>TextPad</b> - <a href="http://www.textpad.com/">
  958.         http://www.textpad.com</a> 
  959.  
  960.         <ul>
  961.           <li>TextPad is a fully featured text editor for Windows.
  962.           16 and 32 bit editions available.</li>
  963.         </ul>
  964.         <br />
  965.       </li>
  966.  
  967.       <li>
  968.         <b>UltraEdit</b> - <a href="http://www.ultraedit.com/">
  969.         http://www.ultraedit.com/</a> 
  970.  
  971.         <ul>
  972.           <li>UltraEdit is a disk based editor with a 16-Bit
  973.           version for Windows 3.x and a 32-Bit version for Windows
  974.           NT and Windows 95 (not Win32s). It includes bazillions of
  975.           features including a Perl wordfile for Perl syntax
  976.           highlighting.</li>
  977.         </ul>
  978.         <br />
  979.       </li>
  980.  
  981.       <li>
  982.         <b>VIM</b> - <a href="http://www.vim.org/">
  983.         http://www.vim.org</a> 
  984.  
  985.         <ul>
  986.           <li>The "Vi IMproved" editor -- Now with Perl support.
  987.           VIM provides Perl syntax highlighting, and a Perl
  988.           interface. The Perl interface provides the ability to run
  989.           a Perl command or run a Perl command for each line in a
  990.           range. For more information on Perl support, see the Perl
  991.           and VIM help page.</li>
  992.         </ul>
  993.         <br />
  994.       </li>
  995.  
  996.       <li>
  997.         <b>VisualSlickEdit</b> - <a href=
  998.         "http://www.slickedit.com/">http://www.slickedit.com</a> 
  999.  
  1000.         <ul>
  1001.           <li>Visual SlickEdit combines the richest set of powerful
  1002.           editing features with more configurability than any
  1003.           software product in any category. Visual SlickEdit is
  1004.           multi-platform, highly extensible, and fast -- Includes
  1005.           language color-coding extention for Perl.</li>
  1006.         </ul>
  1007.         <br />
  1008.       </li>
  1009.  
  1010.       <li><b>WinEdit</b> - <a href= 
  1011.       "http://www.windowware.com/winware/winedit.html">
  1012.       http://www.windowware.com/winware/winedit.html</a> <br />
  1013.       </li>
  1014.     </ul>
  1015.     <br />
  1016.     <hr />
  1017.  
  1018.     <h1><a name="AUTHOR_AND_COPYRIGHT">AUTHOR AND
  1019.     COPYRIGHT</a></h1>
  1020.  
  1021.     <p>This <font size="-1">FAQ</font> was originally assembled and
  1022.     maintained by Evangelo Prodromou. <a href= 
  1023.     "mailto:evangelo@endcontsw.com">evangelo@endcontsw.com.</a> It
  1024.     has been revised and updated by Brian Jepson of O'Reilly and
  1025.     Associates, and David Grove, David Dmytryshyn of ActiveState,
  1026.     Kevin Meltzer and Eric Smith.</p>
  1027.  
  1028.     <p>This <font size="-1">FAQ</font> is in the public domain. If
  1029.     you use it, however, please ensure that you give credit to the
  1030.     original authors.</p>
  1031.  
  1032.     <p><!-- beginning of leaf footer--></p>
  1033.  
  1034.     <table width="100%">
  1035.       <tr>
  1036.         <td bgcolor="000000" width="70" height="31"><a href= 
  1037.         "http://www.activestate.com/"><img src="ASbutton.gif" alt= 
  1038.         "ActiveState Home Page" border="0" width="68" height=
  1039.         "30" /></a></td>
  1040.  
  1041.         <td width="10"> </td>
  1042.  
  1043.         <td valign="middle" bgcolor="#cc0066"><font face=
  1044.         "sans-serif" size="+1" color="#ff99cc">   
  1045.         Win32 FAQ</font></td>
  1046.       </tr>
  1047.     </table>
  1048.     <!-- end  of leaf footer-->
  1049.   </body>
  1050. </html>
  1051.  
  1052.