Running a Perl script as a service is actually very easy and requires no extra coding. The only thing that I have noticed with the following method is that the script doesn't really shut down. It is just stopped.
Any script can be run as a service if you use the srvany application that comes with the Windows Reource Kit tools. Download the resource kit from microsoft and read the documentation regarding InstSrv.exe and SrvAny.exe. The first tool installs a service. The service that you install is SrvAny. Registry settings for SrvAny tell it which application to run as a service.
The following are some notes that I made for a Perl App that is installed as a service.
Manual Installation
===================
Manual installation requires that the INSTSRV.EXE utility is used to i
+nstall the
service. The Service is subsequently configured by creating registry s
+ettings.
1. run INSTSRV.EXE SERVICENAME C:\path\SRVANY.EXE
2. configure the parameters etc. in the registry as described below
3. Start the service
Registry Settings
=================
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SearchWatcher\Pa
+rameters]
"Application"="C:\\Perl\\bin\\Perl.exe"
"AppParameters"="SearchWatcher.pl SearchWatcher.ini"
"AppDirectory"="C:\\SearchWatcher\\SearchWatcher"
Application is the executable to run.
AppParameters are any parameters that are to be passed to the applicat
+ion
AppDirectory is the working directory to use.