The wish is to enhance Index to be a range, i.e.
gettoken($string, "$from|$to", $sep)
(OK: count would do as well. Could even be an additional operand?)
The format is just an idea/example - I know that it's not ideal.
Reason: performance!
I have a big! text file in $text, about 8000 lines (= tokens), and have to mix it with a few (~ 2-4) (small) group of lines.
So copy great block of lines, concat an insert, concat next block, ...
Timing-tests show: if I copy lines by gettoken in loop, i.e.
Code: Select all
$count = 1000;
$dest = '';
$i = 0;
while $i < $count {
$i += 1;
$dest .= gettoken($text, $i, <crlf>);
}
(OK: slow laptop.)
The same copied by
Code: Select all
$dest .= gettoken($text, $count, <crlf>, , 1)
(It seems the smallest time diff is 15|16 msec.)
So speed diff is about factor 1000 (i.e. 100000%)
With some logic I can copy 1st and last block by "from start" or "to end", but every middle block ...
And so my wish for a command to copy any block with 1 cmd (with from|to token number).
- if from|to is specified, 4:= should be disabled (makes no sense).
- from|to should each allow negative values (i.e. count from end)