in reply to Best ways to run a windows batch with Perl

Which are the plus and minuses of executing a Windows batch with system or with exec?

Pluses and minuses as compared to what? Since you apparently want your Perl script to continue running, you want system, not exec. Even though it's been a while since I used it on Windows, system should return even if the batch file blows up, then you'll need to inspect the return codes as per its documentation. Or, to make your life easier, use a module like IPC::System::Simple, which has nicer error handling built in.

When coded with portability in mind, such as using the right modules (like File::Spec or similar for filename handling), Perl is quite portable. For platform-specific notes see perlport (also perlwin32 might contain some useful hints).

  • Comment on Re: Best ways to run a windows batch with Perl

Replies are listed 'Best First'.
Re^2: Best ways to run a windows batch with Perl
by luxAeterna (Acolyte) on Nov 28, 2014 at 11:36 UTC

    I meant system/exec compared to each other :)

    Unluckily I can't immediately include modules for the CPAN. I can only ask for them to be included in the "official next version of Perl", this ensures that all the servers and machines Perl versions are identical and contain the same packages, but it is bureaucratically slow-ish.

    I will though request the modules you suggest and insist that they are essential if they want Perl scripts that work both in Unix and Windows servers, and I will also read the notes you suggest about portability.

    Thank you very much for your approach :)