views:

249

answers:

3

What is the most cross platform way to execute a pPerl script from ant?

Windows does not like the Perl script as the executable. Is there any way other than just running Perl using an OS specific executable and passing the Perl script in as an argument?

+1  A: 

Have you tried creating a custom Ant target for calling Perl (let's call it call-perl-script), and the implementation of that task switches to another subtask based on the OS (like call-perl-script-windows, call-perl-script-osx, etc.)?

Something based on this previous question, or this or this?

Shaggy Frog
I was trying to not do specific os checks.
Gambit
There's no way around it. If you want your Ant targets to work on different platforms, when it comes to platform-specific functionality (like launching a process) you're going to have to, at some point, write platform-specific code. What I'm suggesting is wrapping it up nicely.
Shaggy Frog
A: 

Have you considered the ant <exec> command? You can use the os attribute to specify which operating system to use.

The catch would be that you would need a specific call for each known operating system the Perl script will be used on. Its probably safer to do an os check anyway.

John McG
A: 

Windows does not like the Perl script as the executable.

Either you configure windows to execute .pl files (help ftype, help assoc)

ftype PerlScript=perl.exe %1 %*
assoc .pl=PerlScript

or you run the script through pl2bat (happens automatically if you use ExtUtils::MakeMaker to install script). If you use pl2bat, please examine the resulting file and make sure you're satisfied with the results.

you could also use PAR/pp to create an .exe

yo