Hmm, here we go; still two m//'s though:

$_ = "Here are 15 interesting values to parse: 12.3 14 acd  3.14 ...";
if (m/^Here are (\d+) ...*? parse:/g && (my @d = (m/\s*(\S+)/g)[0..$1-1]) ) {
   # do something with @d; perhaps worry about resetting pos() for any
   # more matching I might need to do ...
}

OK, can this be condensed to something simpler (but perhaps still
readable?)

-Aaron

On Fri, 12 Jul 2002, Aaron J Mackey wrote:

> $_ = "2aaa";
> @d = s/^(\d+)//;
> push @d, m/(a)/ for 1..$d[0];
>
> My "real" application is something like:
>
> $_ = "Here are 15 interesting values to parse: 12.3 14 acd  3.14 ...";
> # try to fill @d with 15 things in one step:
> if (@d = m/^Here are (\d+) .*? to parse:(?:\s*(\S+)){\1}/) {
>   # do stuff with @d;
> }
>
> Yes, I realize there are easy ways to accomplish what I want, but that's
> not fun with perl, is it?
>
> -Aaron
>

-- 
 Aaron J Mackey
 Pearson Laboratory
 University of Virginia
 (434) 924-2821
 [EMAIL PROTECTED]


Reply via email to