Eule has asked for the wisdom of the Perl Monks concerning the following question:
Before:
After:$result = `$cmd $args`;
As you might have noticed, the latter form needs the arguments splitted up into a list, the former one just a plain string. For simple arguments of course 'split' will do the trick. But what about arguments that contain white space? If $args is something likeopen ($fh, '-|', $cmd_file, @args); $test_result = <$fh>;
a simple split at whitespace would certainly produce a wrong argument list. Now the shell could of course do this, but the point of removing the backticks was to get rid of the shell in the first place.-w 70 -c 80 -r 'bla bla'
So my question: How can I split up a string into an argument list just as the shell would do it? Including escape characters like ' " \ ...
Thanks,
Christopher
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Switching from backticks to open
by repellent (Priest) on Nov 03, 2008 at 08:45 UTC | |
by ikegami (Patriarch) on Nov 03, 2008 at 09:04 UTC | |
by repellent (Priest) on Nov 03, 2008 at 17:51 UTC | |
by Eule (Novice) on Nov 03, 2008 at 11:05 UTC | |
|
Re: Switching from backticks to open
by ikegami (Patriarch) on Nov 03, 2008 at 09:10 UTC |