Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Operating System - Microsoft
Showing results for 
Search instead for 
Did you mean: 

Perl Help in Windows Environment

Go to solution
Steven Chen_1
Super Advisor

Perl Help in Windows Environment

Being new for Perl, I would like to seek help about using it on Windows platform:

1) what should the 1st line be in *.pl file:


the combination?

2) how to execute perl on schedule, not from cmd manually. could that be:

a) xxx.bat
b) inside xxx.bat --> perl

Any help is greatly appreciated!


A. Clay Stephenson
Acclaimed Contributor

Re: Perl Help in Windows Environment

You should note that the "shebang" syntax has no meaning in a windows environment (unless you are running SFU -- Microsoft Services for UNIX --- and are running under a UNIX-like shell). Because it begins with '#', it is treated as a comment by Perl. I just leave my scripts as:
#!/usr/bin/perl -w so that they work as intended in UNIX land. Windows handles the association of a file to an executable in an entirely different way. Windows uses filename extensions (e.g. .pl) to automatically associate .pl files with Perl.exe. In UNIX, filename extensions are absolutely meaningless except for conventions and except for any associations that might be built into an application.

In Windows:
My Computer -> Tools -> Folder Options ->File Types is where the .pl to Perl association is done although that is typically is done for you when Perl is installed.

If you need to execute Perl in a cron-like manner then you need to use a cron-like tool. Pick one and use it.

You also asked this question in the OmniBack/Data Protector forum and there are some special rules for using Perl as a pre/post-exec command. See my response there.
If it ain't broke, I can fix that.
curt larson_1
Honored Contributor

Re: Perl Help in Windows Environment

windows uses file associations based on the filename extentions, i.e. if you have your file associations set up right all you need is the .pl at the end of the file name for windows to know it is a perl file

#! is just another comment on windows

a .bat file is not necessary, but it is nice to use because you can redirect the output to log file such that you can review any error messages that might have occured
Honored Contributor

Re: Perl Help in Windows Environment

Hi Steven,

To address your second question: I would create a batch file that executes your perl code (e.g. "perl.exe"). If you associate '.pl' files with 'perl.exe', you won't need the batch file. Then create a Scheduled Task.

Start->Settings->Control Panel->Scheduled Tasks->Add Scheduled Task