Hi Luca, On Wed, 1 Mar 2017 10:01:34 +0100 Luca Ferrari <fluca1...@infinito.it> wrote:
> Hi all, > I'm not sure if this is possible, but imagine I've got a line as follows: > > command arg1 arg2 arg3 arg4 ... > > I would like to capture all args with a single regexp, possibly with a > named capture, but I don't know exactly how to do: > > my $re = qr/command\s+(?<arg>\w+)+/; > > the above of course is going to capture only the first one (one shoot) > or the last one within a loop. > How can I extract the whole array of arguments? > Perhaps try using \G and the /g and possibly /o flags , see: http://perl-begin.org/uses/text-parsing/ (Note that perl-begin is a site that I maintain). Regards, Shlomi Fish > Please note, a raw solution is to remove the command and split, but > I'm asking for a more elegant solution. > > Thanks, > Luca > -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Freecell Solver - http://fc-solve.shlomifish.org/ It is a good idea to stop worrying about problems (or “problems” in quotes) that cannot be fixed. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/