
linebreak.pl v1.2

It is the Perl program to split long lines in text to shorter. Its formats:

perl linebreak.pl [-big|-gradually] [file_name] start_position max_line_length
perl linebreak.pl -version
perl linebreak.pl -help

Default values of line length are 68 and 80.

(c)2024, Vartiklis, Jonas Skendelis. The linebreak.pl is distributed
under MIT License (see license.txt file) allowing to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell its copies. 
Its copyright notice and license text shall be included in all copies
or substantial portions of this Software.


Detailed description

Two parameters are used to control splitting: one to define the minimal
length and another to define maximal length. A line part till minimal
length is kept as is and then further the space is searching to make
the split in that position. If space was not find then break happens
at maximal length position.

The command below reads a text from standard input (console) and breaks
line leaving at least of 70 symbols but not longer as 90 symbols. The
break will be done at first space after 70th position. The result will
be to standard output stream (console).

perl linebreak.pl 70 90

But it is possible to redirect a result into a file (by using >), for
example, 
perl linebreak.pl 70 90 > splited.txt

Input file could be taken from redirection into input stream (by using
<), for example,

perl linebreak.pl 70 90 <text.txt
or transferring in pipe (by using | ), for example,
more text.txt | perl linebreak.pl 70 90
or providing in first position of command, for example,
perl linebreak.pl text.txt 70 90

And even more. By default a full text is read at once. But if the file
is big and computer resources are low, it would be better to read the
file line by line. That is allowed by parameter  -big or -gradually (they
are equivalent and do the same thing) provided in first place. If this
parameter is set, the text will be read line by line. For example:
perl linebreak.pl -big text.txt 70 90
perl linebreak.pl -big 70 90
or
perl linebreak.pl -gradually text.txt 70 90
perl linebreak.pl -gradually 70 90


Planned upgrades

It is planned to add more features into linebreak and bring it to other
environments:  Python, Linux shell (batch files), C/C++, and, maybe, to more.

Note: it is already into awk.


Versions

1. First version was demo version. Its code is at page:
http://www.lithuanian.net/advancedhtml/perl.htm#linebreak

2. v1.1. version:
Differences of 1.2  from version 1.1:
a) small updates of formatting informational messages;
b) increased performance (more than 2 times) by using built-in function;
c) allowed to use default values for line length;
d) updated description (readme files).
