in reply to Parsing arguments with surrounding garbage.
Since you want "1234 221", not "1234", which is what that regex will capture, and you really want to be using match, not substitute, I'd suggest this:
#!/usr/bin/perl -w use strict; my @args; my $string="garbage validcommand 1234 221 garbage 999 213"; while ($string =~ m!validcommand\s+(\d+(?:\s+\d+)*)!g) { push(@args, $1); } print @args;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Parsing arguments with surrounding garbage.
by kschwab (Vicar) on Apr 04, 2001 at 19:14 UTC |
In Section
Seekers of Perl Wisdom