in reply to passing params to an exe in a perl script

Are you sure the bash syntax  myexe <<... isn't the same as pipe? same as  echo ... | myexe?

Replies are listed 'Best First'.
Re^2: passing params to an exe in a perl script
by Anonymous Monk on Jul 05, 2012 at 11:29 UTC
    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.

      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

      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.