in reply to Line truncation and validation of no of characters


You mean check if it has or exceeds 70 characters?
i.e. each line should not exceed 69 characters


Your $smallchunk will be 69 characters or less.

perl -lne 'chomp; print join "\n", unpack("(a69)*", $_)' textfile > tm +pfile

FYI: Text::Wrap is a paragraph formatter, and may not break your lines at exactly after the 69th character, given $Text::Wrap::columns = 70.

Update: Applied change - thanks, jwkrahn!

Replies are listed 'Best First'.
Re^2: Line truncation and validation of no of characters
by jwkrahn (Abbot) on Sep 24, 2008 at 09:54 UTC

    The unpack template  "A69" will remove trailing whitespace so the string returned may be less than 69 characters long.   Better to use  "a69" as that will not modify the return string.

Re^2: Line truncation and validation of no of characters
by harishnuti (Beadle) on Sep 24, 2008 at 06:36 UTC

    Thanks for the oneliner , iam using it , really helpfull.. this is what i exactly needed..