Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
ipc::run3 portabilityby murrayn (Sexton) |
on Feb 03, 2017 at 02:48 UTC ( [id://1180917]=perlquestion: print w/replies, xml ) | Need Help?? |
murrayn has asked for the wisdom of the Perl Monks concerning the following question: I have a Perl script which should run on Windows, Linux or proprietary Unix systems (subject to the proprietary OS vendors providing a moderately current Perl environment!). I am building a command ARRAY comprising the command name followed by a series of -keyword value pairs: @cmd = (@cmd, "-key1", "value", "-key2", "value2"); This process works happily when I run it on Windows (10, Server 2012) and on Linux (CentOS 7) UNLESS one of the values is blank (a literal space character). If I code @cmd = (@cmd, "-key1", " ", "-key2", "value2"); Windows handles this correctly and passes the space as the value of key1 but Linux attempts to pass "-key2" as the value of key1 and the invoked command suffers fatal conniptions! If I place single or double quotes around the space character, both platforms object to receiving "' '" since the application expects either an X or a space (without enclosing quotation marks). When I copy the failing command line to the Linux shell prompt it fails unless I manually insert a pair of quotes around the space character. Can anybody advise on how to pass an unquoted space character via ipc::run3 please?
Back to
Seekers of Perl Wisdom
|
|