5 ms·
The omission of Perl from this post was pretty striking - not even mentioned in the final thoughts (instead thought to do the whole thing in awk??). Perl has f
by Zhyl 3y ago
The omission of Perl from this post was pretty striking - not even mentioned in the final thoughts (instead thought to do the whole thing in awk??).
Perl has fallen from grace as a general programming language and even as a systems administration language, but it's still absolutely the best and most ubiquitous tool for text manipulation.
- undershirt 3y agoCan 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`?
- shawn_w 3y agoEasily, 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. https://perldoc.perl.org/Text::Balanced https://perldoc.perl.org/Text::Balanced https://perldoc.perl.org/Text::Wrap https://perldoc.perl.org/Text::Wrap
- undershirt 3y agoCould you write it for me as a one-liner? I’d like to learn more Perl and this would help.
- shawn_w 3y agoOh, 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...
- undershirt 3y agoJust a normal program then? No edge cases needed
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]