in reply to Re: passing params to an exe in a perl script
in thread passing params to an exe in a perl script

If I use a pipe then I get the prompt as well as the result as part of the return value. Using a here document doesn't return the prompt.
  • Comment on Re^2: passing params to an exe in a perl script

Replies are listed 'Best First'.
Re^3: passing params to an exe in a perl script
by Anonymous Monk on Jul 05, 2012 at 11:44 UTC

    What qx is doing is calling the shell perl -V:sh, and shell usually doesn't like newlines (which is apparently why in bash you use heredoc), so you have to quote/escape/encode/serialize those args, for which you can use String::ShellQuote ( or Win32::ShellQuote )

    Or use IPC::Run3, its not backticks but it handles quoting for you

    Or use IPC::System::Simple capturex, its close to backticks, and it can handles quoting for you

Re^3: passing params to an exe in a perl script
by ww (Archbishop) on Jul 05, 2012 at 12:08 UTC
    You could, of course, accept "the prompt as well as the result as part of the return value" and then remove the prompt -- with the likes of =~ s///;, among other possibilities.