I want to have Getopt::Std parse a "command line" for me, but the "command line" is coming from STDIN. I've done a simple "split /\s+/" to @ARGV, but that doesn't account for parameters with spaces surrounded by quotes:
use Getopt::Std; ## This works in general $cmdline = '-a b -c d'; @ARGV = split /\s+/, $cmdline; getopts( "a:c:" ); ### ...but this obviously fails: $cmdline = '-a "hello world" -b "some \"text\""';
The quoting and escaping is typically done by the *shell*. Any ideas to turn a scalar into an array for @ARGV? Using modules is OK provided they're part of the standard Perl distro; adding modules is not an option. Google's not being helpful.
Thanks!
In reply to Scalar to @ARGV for Getopt::Std by c64whiz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |