home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _ae6ecca662e7cbaceba17a7791852c9c < prev    next >
Encoding:
Text File  |  2004-06-01  |  30.4 KB  |  593 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3.  
  4. <head>
  5. <title>Windows NT/2000 and Windows 9x</title>
  6. <link rel="STYLESHEET" href="../../Active.css" type="text/css" media="screen">
  7. </head>
  8.  
  9. <body>
  10.  
  11. <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EAE2BB">
  12. <tr> 
  13. <td width="57"><a target=_blank href="http://www.ActiveState.com/ActivePerl/">
  14. <img src="../../images/activeperl_logo.gif" width="57" height="48" border="0" alt="ActivePerl"></a></td>
  15. <td><div align="center" class="heading">ActivePerl User Guide</div></td>
  16. <td width="112"><a target=_blank  href="http://www.ActiveState.com">
  17. <img src="../../images/AS_logo.gif" width="112" height="48" border="0"  alt="ActiveState" /></a></td>
  18. </tr>
  19. <tr>
  20. <td class="lineColour" colspan="3"></td>
  21. </tr>
  22. </table>
  23.  
  24. <h1>Windows NT/2000 and Windows 9x</h1>
  25.  
  26. <ul>
  27.   <li><a class="doc" href="#NAME">NAME</a></li>
  28.   <li><a class="doc" href="#DESCRIPTION">DESCRIPTION</a>
  29.     <ul>
  30.       <li><a class="doc" href="#Where_can_I_get_Windows_2K_infor">Where can I get Windows 2000
  31.       information?</a></li>
  32.       <li><a class="doc" href="#Where_can_I_get_Windows_NT_infor">Where can I get Windows NT
  33.         information?</a></li>
  34.       <li><a class="doc" href="#Where_can_I_get_Windows_9x_infor">Where can I get Windows
  35.         9x information?</a></li>
  36.       <li><a class="doc" href="#What_s_the_equivalent_of_the_she">What's the equivalent of
  37.         the shebang ("#!") syntax for Win32?</a></li>
  38.       <li><a class="doc" href="#What_s_the_equivalent_of_chmod_f">What's the equivalent of
  39.         chmod for Win32?</a></li>
  40.       <li><a class="doc" href="#How_do_I_send_email_from_Perl_fo">How do I send email from
  41.         ActivePerl?</a></li>
  42.       <li><a class="doc" href="#How_do_I_schedule_jobs_on_Win32_">How do I schedule jobs on
  43.         Win32 platforms?</a></li>
  44.       <li><a class="doc" href="#Where_can_I_find_Win32_ports_of_">Where can I find Win32
  45.         ports of UNIX tools?</a></li>
  46.       <li><a class="doc" href="#What_is_a_Windows_NT2000_service_">What is a Windows NT/2000 service?</a></li>
  47.       <li><a class="doc" href="#How_do_I_run_a_Perl_script_as">How do I run a Perl script as
  48.         a Windows NT service?</a></li>
  49.       <li><a class="doc" href="#How_do_I_set_permissions_on_a_fi">How do I set permissions
  50.         on a file?</a></li>
  51.       <li><a class="doc" href="#How_do_I_associate_Perl_scripts_">How do I associate Perl
  52.         scripts with perl?</a></li>
  53.       <li><a class="doc" href="#perl_dash_e">Why doesn't "perl -e" work?</a></li>
  54.       <li><a class="doc" href="#What_editors_are_available_for_Windows">What editors are
  55.         available for Windows?</a></li>
  56.     </ul>
  57.   </li>
  58.   <li><a class="doc" href="#AUTHOR_AND_COPYRIGHT">AUTHOR AND COPYRIGHT</a></li>
  59. </ul>
  60.  
  61. <h2><a name="NAME">NAME</a></h2>
  62. <p>ActivePerl-faq4 - Windows NT/2000 and Windows 9x</p>
  63.  
  64. <h2><a name="DESCRIPTION">DESCRIPTION</a></h2>
  65. <p>Useful information about Windows NT/2000 and Windows 9x for Perl developers</p>
  66.  
  67. <h2><a name="Where_can_I_get_Windows_2K_infor">Where can I get Windows 2000
  68. information?</a></h2>
  69. <p>The help files enclosed with Windows 2000 are an excellent source of information
  70. and can answer most of your questions about Windows 2000.
  71. <p>World Wide Web support for Windows 2000 can be found at:</p>
  72. <blockquote>
  73. <a class="doc" href="http://support.microsoft.com/windows2000/">http://support.microsoft.com/</a>
  74. </blockquote>
  75.  
  76. <h2><a name="Where_can_I_get_Windows_NT_infor">Where can I get Windows NT
  77. information?</a></h2>
  78. <p>A good starting place is the printed documentation that came with Windows NT
  79. and on the Windows NT CD in the <em>support\books</em> directory. Windows Help
  80. files are also available.</p>
  81. <p>You can get some in-depth information on Windows NT from the Windows NT
  82. Resource Kit, available at bookstores and from Microsoft. Microsoft TechNet is
  83. also a valuable resource.</p>
  84. <p>World Wide Web support for Windows NT Server is at:</p>
  85. <blockquote>
  86. <a class="doc" href="http://www.microsoft.com/ntserver/">http://www.microsoft.com/ntserver/</a>
  87. </blockquote>
  88. <p>Support for Windows NT Workstation is at:</p>
  89. <blockquote>
  90. <a class="doc" href="http://www.microsoft.com/ntworkstation/">http://www.microsoft.com/ntworkstation/</a>
  91. </blockquote>
  92.  
  93. <h2><a name="Where_can_I_get_Windows_9x_infor">Where can I get Windows 9x
  94. information?</a></h2>
  95. <p>Printed documentation comes with Windows 9x, as well as some documentation
  96. on the CD-ROM. Help files are available from the Start menu.</p>
  97. <!-- <p>The Windows 95 Resource Kit contains in-depth information on Windows 95. It's
  98. available at bookstores and software stores.</p>-->
  99. <p>World Wide Web support for Windows 9x is at:</p>
  100. <blockquote>
  101. <a class="doc" href="http://www.microsoft.com/windows95/">http://www.microsoft.com/windows95/</a>
  102. </blockquote>
  103. <blockquote>
  104. <a class="doc" href="http://www.microsoft.com/windows98/">http://www.microsoft.com/windows98/</a>
  105. </blockquote>
  106.  
  107. <h2><a name="What_s_the_equivalent_of_the_she">What's the equivalent of the
  108. shebang ("#!") syntax for Win32?</a></h2>
  109. <p>Unfortunately, Win32 platforms don't provide the shebang syntax, or anything
  110. like it. You can try one of the two following methods to run a script from the
  111. command line. If all else fails, you can always just call the perl interpreter
  112. directly, as in <code>perl myscript.pl</code>.</p>
  113.      
  114. <p>Although Win32 systems themselves don't use the shebang, the Apache webserver
  115. does. If you are using the Apache webserver on your Win32 system you should put
  116. the shebang line at the top of your CGI scripts.</p>
  117.      
  118. <p>Your shebang line should look something like:</p>
  119. <pre> #!perl
  120. </pre>
  121.  
  122. <p>For Windows NT 4.0/2000, the coolest method is to use associated file types (see <a class="doc" href="#How_do_I_associate_Perl_scripts_">How
  123. do I associate Perl scripts with perl?</a>). If you've associated Perl scripts
  124. with the <em>.pl</em> extension, you can just type the name of your file at the
  125. command line and Windows NT/2000 will launch <em>perl.exe</em> for you. If you change
  126. the <code>PATHEXT</code> environment variable to include <em>.pl</em> files,
  127. like this:</p>
  128. <pre>    SET PATHEXT=.pl;%PATHEXT%
  129. </pre>
  130. <p>you can just type the file name without an extension, and Windows NT/2000 will
  131. find the first <em>.pl</em> file in your path with that name. You may want to
  132. set <code>PATHEXT</code> in the System control panel rather than on the command
  133. line. Otherwise, you'll have to re-enter it each time the command prompt window
  134. closes.</p>
  135. <p>Given this setup, you can have a Perl script called <em>cat.pl</em> that
  136. looks like this:</p>
  137. <pre>    while ( <> ) {
  138.         print;
  139.     }
  140. </pre>
  141. <p>and you can invoke it on the command line like this:</p>
  142. <pre>    cat myfile.txt
  143. </pre>
  144. <p>However, you can't invoke it with I/O redirection, like this:</p>
  145. <pre>    cat < myfile.txt
  146.     cat myfile.txt | more
  147. </pre>
  148.  
  149. <p>although it looks like you should be able to (this is a limitation of Windows
  150. NT/2000). Your script can be in your path or you can provide a path to the file.</p>
  151. <p>Note that the file association method does not work for Windows 9x, nor does
  152. it work with Windows NT/2000 if you have command extensions disabled. You can,
  153. however, still start the Perl script from an Explorer window if the extension is
  154. associated with perl.</p>
  155. <p>Another option is to use the pl2bat utility distributed with ActivePerl to
  156. convert your Perl script into a batch file. What this does is tag some Win32
  157. batch language to the front of your script so that the system calls the perl
  158. interpreter on the file. It's quite a clever piece of batch coding, actually.</p>
  159. <p>If you call the pl2bat utility on your Perl script <em>helloworld.pl</em>,
  160. like this:</p>
  161. <pre>    C:\> pl2bat helloworld.pl
  162. </pre>
  163. <p>it will produce a batch file, <em>helloworld.bat</em>. You can then invoke
  164. the script just like this:</p>
  165. <pre>    C:\> helloworld
  166.     Hello, World!
  167. </pre>
  168.  
  169. <p>You can pass command line parameters, as well. Your script can be in your <code>PATH</code>,
  170. or in another directory, and the pl2bat code will usually find it and execute it
  171. correctly. The big advantage of this over file associations is that I/O
  172. redirection will work correctly.</p>
  173. <p>pl2bat has a number of useful command line options to affect how the wrapping
  174. is done, what command line switches to pass to perl, etc. Running <code>perldoc
  175. pl2bat</code> at the command line will show a full description of these options.</p>
  176. <p>PerlApp, available in the <a class="doc" href="ActivePerl-Winfaq2.html">Perl Dev Kit</a> 
  177. creates standalone .exe files from Perl Scripts.  Redirection works 
  178. correctly on PerlApp .exe files.</p>
  179.  
  180. <h2><a name="What_s_the_equivalent_of_chmod_f">What's the equivalent of chmod
  181. for Win32?</a></h2>
  182. <p>There is no direct equivalent of the chmod tool on Win32 systems. For file
  183. attributes, you can use the <em>ATTRIB</em> command line tool (type <code>HELP
  184. ATTRIB</code> at the command line for details). For more complex permissions,
  185. see <a class="doc" href="#How_do_I_set_permissions_on_a_fi">How do I set permissions on a
  186. file?</a>.</p>
  187. <p>For information on the <code>chmod()</code> function, see <a class="doc" href="ActivePerl-Winfaq5.html#How_does_the_chmod_function_work">How
  188. does the chmod function work on Win32 platforms?</a>.</p>
  189.  
  190. <h2><a name="How_do_I_send_email_from_Perl_fo">How do I send email from
  191. ActivePerl?</a></h2>
  192. <p>You may come across scripts that send email with an external mail program, as
  193. in:</p>
  194. <pre>   
  195.         open(MAIL, '| /usr/lib/sendmail user@there.com') or "die";
  196.         print MAIL <<EOF;
  197.         To: user@there.com
  198.         From: user@here.com
  199.         Hello, World!
  200.         EOF
  201. </pre>
  202. <p>These sort of scripts generally cause people to ask, "is there a sendmail
  203. equivalent on Windows?'' If you need to send email from a Perl script, there is
  204. no need to use an external program like sendmail. The libnet bundle includes <code>Net::SMTP</code>,
  205. a module that can be used to send mail. Here is an example:</p>
  206. <pre> 
  207.         use Net::SMTP;
  208.  
  209.         $smtp = Net::SMTP->new('here.com'); # connect to an SMTP server
  210.         $smtp->mail( 'user@here.com' );     # use the sender's address here
  211.         $smtp->to('user@there.com');        # recipient's address
  212.         $smtp->data();                      # Start the mail
  213.  
  214.         # Send the header.
  215.         $smtp->datasend("To: user@there.com\n");
  216.         $smtp->datasend("From: user@here.com\n");
  217.         $smtp->datasend("\n");
  218.  
  219.         # Send the body.
  220.         $smtp->datasend("Hello, World!\n");
  221.         $smtp->dataend();                   # Finish sending the mail
  222.         $smtp->quit;                        # Close the SMTP connection
  223. </pre>
  224. <p>Another alternative is Mail::Sender, which can be used like so:</p>
  225. <pre>        use Mail::Sender;
  226.      
  227.         $sender = new Mail::Sender {smtp => 'mail.yourdomain.com', from => 'your@address.com'};
  228.         $sender->MailFile({to => 'some@address.com', subject => 'Here is the file', 
  229.                        msg => "I'm sending you the list you wanted.", 
  230.                            file => 'filename.txt'});
  231. </pre>
  232. <p>Or Mail::Sendmail, which can be used like this:</p>
  233. <pre>        use Mail::Sendmail;
  234.  
  235.         %mail = ( To      => 'you@there.com',
  236.                   From    => 'me@here.com',
  237.                   Message => "This is a minimalistic message"
  238.                  );
  239.  
  240.         if (sendmail %mail) { print "Mail sent OK.\n" }
  241.         else { print "Error sending mail: $Mail::Sendmail::error \n" }
  242. </pre>
  243. <p>A Perl script for sending mail without using an external program is also
  244. available on Robin Chatterjee's Perl for Win32 page (see <a class="doc" href="../ActivePerl-faq3.html#Are_there_information_sources_av">Are
  245. there information sources available on ActivePerl on the World Wide Web?</a>).
  246. <p>If you really need a sendmail equivalent for Windows, several such
  247. equivalents exist:</p>
  248. <dl>
  249.   <dt><strong><a name="item_Blat">Blat</a></strong></dt>
  250.   <dd>
  251.     <p>Blat is a public domain program for sending email from the Windows NT
  252.     command-line. Although it is reputed to work under Windows 95, the Blat
  253.     authors have not tested it under Windows 98. The Blat home page is located
  254.     at <a class="doc" href="http://www.interlog.com/~tcharron/blat.html">http://www.interlog.com/~tcharron/blat.html</a></p>
  255.   </dd>
  256.   <dt><strong><a name="item_sendmail">sendmail</a></strong></dt>
  257.   <dd>
  258.     <p>Microsoft has a port of sendmail available on their FTP site at <a class="doc" href="ftp://ftp.microsoft.com/developr/drg/unix-to-windows/ports/sendmail/">ftp://ftp.microsoft.com/developr/drg/unix-to-windows/ports/sendmail/</a></p>
  259.     <p>A commercial sendmail product is available from MetaInfo, Inc. An
  260.     evaluation version is available at <a class="doc" href="http://www.metainfo.com/">http://www.metainfo.com/</a></p>
  261.   </dd>
  262.   <dt><strong><a name="item_wrmail">wrmail</a></strong></dt>
  263.   <dd>
  264.     <p>Another commercial mail product is wrmail, part of the slmail product
  265.     from Seattle Labs. A free version is available at <a class="doc" href="http://www.seattlelab.com/">http://www.seattlelab.com/</a></p>
  266.   </dd>
  267. </dl>
  268.  
  269. <h2><a name="How_do_I_schedule_jobs_on_Win32_">How do I schedule jobs on Win32
  270. platforms?</a></h2>
  271. <p>The UNIX cron utility doesn't exist on Win32 platforms.</p>
  272. <p>For Windows 2000, there is a scheduling application available. It can be accessed through the
  273. Start menu: <code>Start | Settings | Control Panel | Scheduled Tasks</code>. By clicking "Add Scheduled Task", you
  274. start the Scheduled Task Wizard which walks you through the process.
  275. <p>For Windows NT, a scheduling tool called <code>AT</code> is available. Unlike
  276. the UNIX cron utility, <code>AT</code> doesn't store its schedule in a flat
  277. file, but is configured using command-line arguments. Note the AT command seems
  278. to be very picky about syntax. Here is one example:</p>
  279. <pre>        at 23:37 /interactive /every:M,T,W,Th,F,S,Su cmd /c "c:\perl\bin\perl.exe c:\test.pl"
  280. </pre>
  281. <p>If you don't like the command-line version of <code>AT</code>, there's a GUI
  282. version, WinAT, which is available with the Windows NT Resource Kit. The
  283. "Schedule" service must be running when your job is supposed to
  284. happen.</p>
  285. <p>Note that you may have problems when running AT or WinAT if the scheduled
  286. program or script requires any special rights or permissions other than those
  287. held by "System" (ie, if it is working across computers or NT
  288. domains). This is because NT does not properly allow you to run preinstalled NT
  289. services, such as the "Schedule" service as a user with network
  290. priveleges. It may <i>look</i> like you can set the scheduler to login as a user
  291. with network priveledges, but the service just does not recognize that user's
  292. right's and permissions and the System userid has only local permissions.</p>
  293. <p>An all-Perl cron-like solution exists at <a class="doc" href="http://www.megadodo.demon.co.uk/perl/">http://www.megadodo.demon.co.uk/perl/</a>
  294. which uses a familiar Unix-like crontab file. This script can be ran as an NT
  295. Service (see <a class="doc" href="#What_is_a_Windows_NT2000_service_">How do I set up a Perl
  296. script as an NT Service?</a>). When you create your own NT service, NT lets you
  297. set the useid/password pair, and these services do recognize that userid's
  298. rights and permissions. Hence, the scheduled program or script will have the
  299. necessary rights.</p>
  300. <p>There are a few commercial cron-like schedulers. NTcrond, is available from
  301. ifdef software: <a class="doc" href="http://www.ifdef.com/">http://www.ifdef.com/</a> and
  302. AutoTask2000 is available from <a class="doc" href="http://www.cypressnet.com/">http://www.cypressnet.com/</a>.
  303. These programs <i>should</i> recognize the rights and priveleges of the userid
  304. you set their service to run under to enable the scheduled program or script to
  305. have the necessary rights.</p>
  306. <p>For Windows 9x, there's a System Agent available with the Microsoft Plus!
  307. Pack. Also, there are several shareware scheduling utilities, notably LaunchPad
  308. and Metz Scheduler. These can be found on a good shareware search engine, such
  309. as <a class="doc" href="http://www.shareware.com/">http://www.shareware.com/</a>. There is
  310. also an optional "Task Scheduler" component with IE4.01 and Windows
  311. 98.</p>
  312. <p>Because scheduled jobs on Windows NT run as a service (see <a class="doc" href="#What_is_a_Windows_NT2000_service_">What
  313. is a Windows NT service?</a>), you need to take special steps to make sure that
  314. files and environment variables are available to your script.</p>
  315. <p>In some instances, Perl's internal <code>sleep</code> function might be an
  316. appropriate means of scheduling. For example:</p>
  317. <pre>        $seconds = 180;
  318.         sub action;
  319.         while(1) {
  320.                 &action;
  321.                 sleep($seconds);
  322.         }
  323. </pre>
  324. <p> </p>
  325.  
  326. <h2><a name="Where_can_I_find_Win32_ports_of_">Where can I find Win32 ports of
  327. UNIX tools?</a></h2>
  328. <p>You might want to take a look at the help file for Windows NT and Windows 9x
  329. commands to see if there's a rough equivalent distributed with your Win32
  330. platform. If not, try one of these URLs:</p>
  331. <ul>
  332.   <li>
  333.     <p>Cygwin - Linux-like environment for Windows, contains many GNU tools, as well as a complete
  334.     development environment. <a class="doc" href="http://www.cygwin.com/">http://www.cygwin.com/</a></p>
  335.   </li>
  336.   <li>
  337.     <p>Virtually Un*x! - various ports of UNIX programs for Win32. <a class="doc" href="http://www.itribe.net/virtunix/">http://www.itribe.net/virtunix</a></p>
  338.   </li>
  339. </ul>
  340. <p>There are also several UNIX-like tools available in the Windows NT Resource
  341. Kit. Also, there are several UNIX-to-Win32 commercial packages available,
  342. including the MKS Toolkit from Mortice Kerns Systems, Inc.: <a class="doc" href="http://www.mks.com">http://www.mks.com/</a>.
  343. <p>You can also check into the Perl Power Tools, being developed under the UNIX
  344. Reconstruction Project. Here you can find UNIX tools that are being
  345. reimplemented into all Perl. You can see the latest at <a class="doc" href="http://language.perl.com/ppt/">http://language.perl.com/ppt/</a></p>
  346.  
  347. <h2><a name="What_is_a_Windows_NT2000_service_">What is a Windows NT/2000 service?</a></h2>
  348. <p>On Windows NT/2000, a service is a special kind of executable program that runs in
  349. the background. Services are used for programs that are constantly working, such
  350. as network protocols or database servers. Most WWW servers on Windows NT/2000 are
  351. implemented as services.</p>
  352. <p>A service is different from other programs in several ways:</p>
  353. <ul>
  354.   <li>
  355.     <p>Services aren't run interactively, although the <code>NET START</code>
  356.     and <code>NET STOP</code> commands can be used to start or stop a server.
  357.     The Services control panel is used to start, stop, or pause a service.</p>
  358.   </li>
  359.   <li>
  360.     <p>Services don't act with the authority of the logged-in user. That means
  361.     that services can't see user environment variables or read files that are
  362.     readable only by the logged-in user. You can set the account that a service
  363.     uses in the Services control panel.</p>
  364.   </li>
  365.   <li>
  366.     <p>Services run even when no one is logged in to the machine.</p>
  367.   </li>
  368. </ul>
  369. <p>The most important thing to remember is that you have to take special steps
  370. to make resources available to services. In general, you need to make files
  371. available to the Everyone group, and you have to have environment variables
  372. (like <code>PATH</code>) be system environment variables.</p>
  373.  
  374. <h2><a name="How_do_I_run_a_Perl_script_as">How do I run a Perl script as a
  375. Windows NT Service?</a></h2>
  376. <p>You can run your Perl scripts as Windows NT Services via a program called
  377. srvany.exe, which comes with the Windows NT Resource Kit. Once srvany.exe is
  378. installed, read the srvany.wri file which should be with it. This document will
  379. explain how to set up registry entries for your new service.</p>
  380. <p>After you are set up, to run your script as a service do:</p>
  381. <pre>  x:>srvany perl script.pl
  382. </pre>
  383.  
  384. <h2><a name="How_do_I_run_a_Perl_script_as_2K">How do I run a Perl script as a
  385. Windows 2000 Service?</a></h2>
  386. <p>You can run your Perl scripts as Windows 2000 Services by accessing the Microsoft
  387. Management Console. The Windows 2000 help files contain plenty of information on how to
  388. start the MMC and how you can use it for Perl scripts.
  389.  
  390. <h2><a name="How_do_I_set_permissions_on_a_fi">How do I set permissions on a
  391. file?</a></h2>
  392. <p>Win32 platforms don't have the same mechanisms for setting permissions on
  393. files as UNIX does. For files on FAT partitions (which means all files in
  394. Windows 9x), you don't have to set permissions explicitly on a file. All files
  395. are available to all users.</p>
  396. <p>For files on an NTFS partition on Windows NT, you can set the security
  397. permissions on a file using the Explorer and the properties sheet of the file.
  398. Right-click the file in Explorer, and choose Properties from the drop-down menu.
  399. Select the Security tab, and click Permissions to set the Permissions on the
  400. file. Click Help for more information.</p>
  401. <p>A command-line program, <code>CACLS</code>, will also change the permissions
  402. on a file. For more details, type <code>HELP CACLS</code> on the command line.</p>
  403. <p>Windows 9x/98 machines that are administered using Novell can have accounts
  404. and permissions similiar to NT. However, these permissions must be set up by the
  405. Novell administrator.</p>
  406.  
  407. <h2><a name="How_do_I_associate_Perl_scripts_">How do I associate Perl scripts
  408. with perl?</a></h2>
  409. <p>On Windows systems, association is the process of specifying which programs
  410. should be used for which kind of files. Files are grouped into file types, such
  411. as JPEG files or Perl scripts. The file type of a file is identified by its file
  412. name extension (all the letters after the last ".'' in the file name).</p>
  413. <p>So, for example, we can say that there's a type of file called a text file,
  414. which has the file extension <em>.txt</em>, and which is handled by the Notepad
  415. program.</p>
  416. <p>Usually, ActivePerl programmers create a file type like Perl Script and
  417. associate the extension <em>.pl</em> with that type. We specify that the perl
  418. interpreter binary, <em>perl.exe</em>, is responsible for that file type.
  419. Several Web servers require that you associate your scripts with <em>perl.exe</em>
  420. before the script can be run.</p>
  421.  
  422. <p>On Windows 2000, you can create a new file type and associate it with the perl
  423. intepreter with it as follows:
  424. <ol>
  425.     <li><p>Double-click on the My Computer icon.</p></li>
  426.     <li><p>From the Tools menu, choose Folder Options. This opens the Folder Options
  427.     dialog box.</p></li>
  428.     <li><p>Choose the File Types tab. This gives you a list of file types currently registered
  429.     (or already associated in Windows 2000).</p></li>
  430.     <li><p>Click the New button.</p></li>
  431.     <li><p>In the File Extension box, type "<code>pl</code>" and click OK.</p></li>
  432.     <li><p>Click the Advanced button. This opens the Edit File Type window.</p></li>
  433.     <li><p>Click the New button. This opens the New Action dialog box. Type "<code>Open</code>"
  434.     in the Action window (as you would want the Perl files to be "opened" by the Perl interpreter).
  435.     Then, either type the full path of the location of the Path interpreter in the Application window, or
  436.     click the Browse button to select the executable file of the Perl interpreter.</p></li>
  437.     <li><p>Click OK to close the New Action window. You can click the Change Icon button, if you want to
  438.     find an icon to match the file type. When you click the Change Icon button, you are given a selection of
  439.     pre-set icons or you can browse to a different location. If you want to use a Perl icon for the .pl files, browse
  440.     to the folder where the Perl interpreter is located, choose the Perl interpreter and click Open. Then click OK
  441.     to close the Change Icon Window.</p></li>
  442.     <li><p>Click OK to close the Edit File Type window.</p></li>
  443.     <li><p>Click Close to close the Folder Options window.</p></li>
  444. </ol>
  445. <p>On Windows 9x and Windows NT 4.0, you can create a new file type and
  446. associate the perl interpreter with it as follows:</p>
  447. <ol>
  448.   <li>
  449.     <p>Open the My Computer icon on the Desktop. The My Computer window should
  450.     appear.</p>
  451.   </li>
  452.   <li>
  453.     <p>From the View menu in the My Computer window, choose Options. The Options
  454.     dialog box appears.</p>
  455.   </li>
  456.   <li>
  457.     <p>In the Options dialog box, select the File Types tab.</p>
  458.   </li>
  459.   <li>
  460.     <p>Click the New Type button. The Add New File Type dialog box appears.</p>
  461.   </li>
  462.   <li>
  463.     <p>In the "Description of type'' box, type "Perl Script''.</p>
  464.   </li>
  465.   <li>
  466.     <p>In the "Associated extension'' box, type ".pl''.</p>
  467.   </li>
  468.   <li>
  469.     <p>Leave the Content Type (MIME) box blank.</p>
  470.   </li>
  471.   <li>
  472.     <p>Click the New button beneath the Actions list. The New Action dialog box
  473.     will appear.</p>
  474.   </li>
  475.   <li>
  476.     <p>In the Action box, type "Open'' (it's important to use this name for the
  477.     action!).</p>
  478.   </li>
  479.   <li>
  480.     <p>In the "Application used to perform action'' box, type <code>[full path
  481.     to perl]\perl.exe %1 %*</code>, where [full path to perl] is the full path
  482.     to <em>perl.exe</em> on your machine. If perl is in your path, you <em>can</em>
  483.     put just <em>perl.exe</em>, but for esoteric reasons it's better to put the
  484.     full path. Also, if the path to your interpreter includes spaces (like <em>C:\Program
  485.     Files\perl5</em>) put in the DOS path instead (<em>C:\progra~1\perl5</em>).</p>
  486.   </li>
  487.   <li>
  488.     <p>Click OK to close the New Action dialog box.</p>
  489.   </li>
  490.   <li>
  491.     <p>Click OK to close the Add New File Type dialog box.</p>
  492.   </li>
  493.   <li>
  494.     <p>Click OK to close the Options dialog box.</p>
  495.   </li>
  496. </ol>
  497. <p>You can test your association by double-clicking on a perl script in the
  498. Explorer window. If <em>perl.exe</em> starts and executes the script, things are
  499. OK.</p>
  500. <p>On Windows NT 4.0, you can avoid all the hassle of the above and just type
  501. the following from the command line:</p>
  502. <pre>    ASSOC .pl=PerlScript
  503.     FTYPE PerlScript=[full path to perl]\perl.exe %1 %*
  504. </pre>
  505. <p>For more information on these commands, type <code>HELP FTYPE</code> at the
  506. command prompt.</p>
  507. <p>Note that for this to work you have to have command extensions enabled.
  508. (These are enabled by default; you'd know if you'd turned them off.)</p>
  509.  
  510. <h2><a name="perl_dash_e">Why doesn't 'perl -e' work?</a></h2>
  511. <p>It does - it's just that some command shells (for example COMMAND.COM,
  512. CMD.EXE and 4DOS) don't accept single quotes wrapped around command arguments.<p>The safest way to do perl one-liners is to wrap the parameters within
  513. "" (double-quotes) the use q() and qq() inside the parameters. q() and
  514. qq() with put whatever is inside them between single-quotes or double-quotes,
  515. respectively.<br>
  516. For example:</p>
  517. <blockquote>
  518.   <p><code>perl -e "use LWP::Simple; while(@c = head <>) { $c = join
  519.   qq(\n\t), @c; print qq(Header info:\n\t$c\n); }"</code>
  520. </blockquote>
  521. <p>(this was all one line)</p>
  522. <p>Run this from the command line and type in the URL to your favorite website,
  523. like <a class="doc" href="http://www.perl.com/">http://www.perl.com/</a>.</p>
  524. <p>The <a class="doc" href="../../lib/Pod/perlwin32.html">perlwin32</a> and <a class="doc" href="../../lib/Pod/perlrun.html">perlrun</a>
  525. POD pages have more information on using the command line.</p>
  526.  
  527. <h2><a name="What_editors_are_available_for_Windows">What editors are available
  528. for Windows?</a></h2>
  529. <p>Windows comes with two editors that are great for editing Perl, NotePad and
  530. WordPad. But, if you need more features for ease of editing, here is a list of
  531. free and commercial editors:</p>
  532. <ul>
  533.   <li><b>Komodo</b> - <a class="doc" href="http://www.ActiveState.com/Products/Komodo/">http://www.ActiveState.com/Products/Komodo/</a>
  534.     <ul>
  535.       <li>Komodo is a complete, powerful development environment for Perl and
  536.         other languages. Komodo also includes the Rx Toolkit, which provides the
  537.         unique ability to interactively step through a regular expression as it
  538.         is being matched, providing support for one of the most difficult
  539.         technologies used in scripting languages.</li>
  540.     </ul>
  541.   </li>
  542.   <li><b>Visual Perl</b> - <a class="doc" href="http://www.ActiveState.com/Products/Visual_Perl/">http://www.ActiveState.com/Products/Visual_Perl/</a>
  543.     <ul>
  544.       <li>Visual Perl is ActiveState's Perl plug-in for Visual Studio.NET.
  545.         Within Visual Studio.NET, Visual Perl provides a full-featured
  546.         integrated development environment that includes all the features of a
  547.         modern IDE such as rich syntax aware editor, method tips, online help,
  548.         and debugger support.</li>
  549.     </ul>
  550.   </li>
  551.   <li><b>MED</b> - <a class="doc" href="http://www.utopia-planitia.de/indexus.html">http://www.utopia-planitia.de/indexus.html</a>
  552.     <ul>
  553.       <li>MED is a powerful shareware text editor for programmers, currently
  554.         available for the platforms Windows 9x/NT4.0/2000.</li>
  555.     </ul>
  556.   </li>
  557.   <li><b>GNU Emacs for Windows</b> - <a class="doc" href="http://www.cs.washington.edu/homes/voelker/ntemacs.html">http://www.cs.washington.edu/homes/voelker/ntemacs.html</a>
  558.     <ul>
  559.       <li>"Emacs is the extensible, customizable, self-documenting
  560.         real-time display editor."</li>
  561.     </ul>
  562.   </li>
  563.   <li><b>VIM</b> - <a class="doc" href="http://www.vim.org/">http://www.vim.org</a>
  564.     <ul>
  565.       <li>The "Vi IMproved" editor -- Now with Perl support. VIM
  566.         provides Perl syntax highlighting, and a Perl interface. The Perl
  567.         interface provides the ability to run a Perl command or run a Perl
  568.         command for each line in a range. For more information on Perl support,
  569.         see the Perl and VIM help page.</li>
  570.     </ul>
  571.   </li>
  572. </ul>
  573.  
  574. <h2><a name="AUTHOR_AND_COPYRIGHT">AUTHOR AND COPYRIGHT</a></h2>
  575. <p>This FAQ was originally assembled and maintained by Evangelo Prodromou. It
  576. has been revised and updated by Brian Jepson of O'Reilly and Associates, and
  577. David Grove, David Dmytryshyn of ActiveState, Kevin Meltzer, Eric Smith and
  578. David Sparks of ActiveState.</p>
  579. <p>This FAQ is in the public domain. If you use it, however, please ensure that
  580. you give credit to the original authors.</p>
  581.  
  582. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  583.   <tr>
  584.     <td class="block" valign="MIDDLE" width="100%" bgcolor="#cccccc"><strong>
  585.       <p class="block"> ActivePerl FAQ - Windows NT and Windows 9x</p>
  586.       </strong></td>
  587.   </tr>
  588. </table>
  589.  
  590. </body>
  591.  
  592. </html>
  593.