Максимальный избыток (и сложность! И ошибки!) Можно получить с помощью модуля Perl Text :: Autoformat .
% < input
1. foo
2. bar 100%
3. kittens
4. it is getting dark. there may be a grue
4. no seriously, it's getting dark
4. really, you should find a light or something.
4. are you even paying attention? helloooo
4. eat cake
5. unicorns
6. rainbows
% perl -MText::Autoformat -0777 -ple '$_=autoformat $_, { all => 1 }' < input
1. foo
2. bar 100%
3. kittens
4. it is getting dark. there may be a grue
5. no seriously, it's getting dark
6. really, you should find a light or something.
7. are you even paying attention? helloooo
8. eat cake
9. unicorns
10. rainbows
%
Фактические результаты будут зависеть от ввода, желаемого результата, переданных опций и т. Д.