pg has asked for the wisdom of the Perl Monks concerning the following question:
In this case, the output should be: 36.72397. (36.72 is the sum of 12.24 and 24.48, 3 is the sum of 1 and 2, 9 is the sum of 3 and 6, 7 is a non-match)sub e1 { shift() *2; } sub e2 { shift() + shift(); } $a = "12.2424.4812367"; $a =~ s/((?:\d+(?:\.\d+)?))((??{e1($+)}))/e2($1, $2)/ge; print $a;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is this enough good, or can be improved?
by Zaxo (Archbishop) on Dec 04, 2002 at 03:38 UTC | |
by pg (Canon) on Dec 04, 2002 at 05:06 UTC | |
by particle (Vicar) on Dec 04, 2002 at 15:14 UTC |