Re:Linux Text Manipulation
by undershirt on Thursday March 28, 2024 @04:18PM
(#39856795)
Can you write a Perl program to replace the content of anything found inside double-quotes with the result of piping it to the command `fmt`?
[ Parent
| on HN ]
Easily, though you don't need to drag external programs like fmt into it - perl comes with a standard module for word wrapping.
Text::Balanced (for extracting the quoted text) and Text::Wrap would be the core of such a program.
Re:Linux Text Manipulation
by undershirt on Thursday March 28, 2024 @06:01PM
(#39857889)
Could you write it for me as a one-liner? I’d like to learn more Perl and this would help.
Oh, I wouldn't try to squeeze it down into a one liner. Maybe for a simple definition of the quoted text that doesn't need to account for edge cases like escaped quotes inside...
Re:Linux Text Manipulation
by undershirt on Thursday March 28, 2024 @09:36PM
(#39859629)
Just a normal program then? No edge cases needed