Sure. Go ahead, provide one.
In general this is a really good idea, especially for regexes that might do some backtracking. In this case it won't happen, so it's not very exiting:
# perl 5.10.0
# match:
Rate REGEX INDEX
REGEX 87061/s -- -1%
INDEX 87682/s 1% --
# fail:
Rate REGEX INDEX
REGEX 43840/s -- -1%
INDEX 44246/s 1% --
Since the found text is in the middle it takes twice as long when there is no match.
| [reply] [d/l] |
After all examples given by all of you I decided that the best way for me to improve my performance is
1) to use regex for forming array
2) regex should be as simple as possible which can be done by adjusting it to my particular case
So could you confirm that it will always work correctly:
my string is always like
143,2|3674,9|12,5|......|145,9
so in |X,Y| Y is always single digit
and I want to have an array of pairs
@arr = (X1,Y1)(X2,Y2)...
Then the simplest way is:
$r = 9; # or any single number
my @arr = $string =~ /([^,|]+\,$r)/g;
It actually works but am I right?
| [reply] [d/l] |