On Wed, Mar 1, 2017 at 2:52 AM, Chas. Owens <chas.ow...@gmail.com> wrote: > Sadly, Perl will only capture the last match of capture with a qualifier, so > that just won't work. The split function really is the simplest and most > elegant solution for this sort of problem (you have a string with a > delimiter and you want the pieces). All of that said, if you are willing to > modify the regex you can say > > my $s = "command arg1 arg2 arg3 arg4"; > my @args = $s =~ /(?:\s+(\w+))/g; >
Hm, I'd write it as: my @args = $s =~ / (\w+)/g; or, if the command check isn't too inelegant: my @args = $s =~ / (\w+)/g if $str =~ /^command\s/; > for my $arg (@args) { > print "$arg\n"; > } > > However, this does not allow you to check the command is correct. > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/