in reply to Parsing a command-line string into an array
You could split on whitespace if none the values are expected to contain whitespace.
But let's say you want to pass -x 123 -y 'some val'.
One approach you could take is
prog [options] -X '-x 123' -X '-y some val' [options] [args]
Split on the first instance of whitespace only.
# my @extra_args = ( '-x', '123', '-y', 'some val' ); my @extra_args = map { split( /\s+/, $_, 2 ) } @opt_X;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Parsing a command-line string into an array
by bliako (Abbot) on Dec 22, 2023 at 12:57 UTC | |
by ikegami (Patriarch) on Dec 23, 2023 at 05:50 UTC |