简体   繁体   中英

How can I force a Perl script to use ActiveState's wperl?

I have a Perl script that requires two command line arguments that takes a while to run. I am using ActiveState Perl to run it. I can call it with

wperl script.pl arg1 arg2
from a command prompt and it runs in the background fine. If I change the .pl association from perl.exe to wperl.exe and call it with
 script.pl arg1 arg2  
the arguments don't get passed. Is there something similar to the #!/usr/bin/perl like I can use to force wperl to get used?

The Perlmonks node wperl.exe vs perl.exe suggests associating the .wpl extension with wperl. Name all the scripts that you want to run under wperl with a .wpl extension and the other .pl named files use the normal perl.exe .

What you can do is change the file association with regards to wperl.exe in the Tools > Folder Options > File Types in any Explorer window and update the .pl extension through Advanced > Open > Edit command line to

{Path to wperl}\wperl.exe "%1" %*

This ensures that all the command line arguments (%*) are passed to wperl.exe whenever you call your script using

script.pl arg1 arg2
unless ($^X =~ m/wperl\.exe$/i) {
    exec "wperl",$0,@ARGV;
    exit 0;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM