in reply to How to have perl check line length
Here's another option that will append a "_" to the end of the three-character elements:
use strict; use warnings; while (<>) { s/\A...\K\Z/_/; print; }
Usage: perl script.pl inFile [>outFile]
The last, optional parameter directs output to a file.
The substitution attempts to match an element that has only three characters, and the \K notation forces the substitution to Keep those three characters, and then adds the "_" to the end of those.
Hope this helps!
|
|---|