sub findwrappoint
{
my ($string, $width) = @_;
my $cut = 0;
my $char = 0;
while( $string =~ /(\e[[\d;]*m)|([^ ]+)|( +)/g )
{
$3 and $char <= $width and $cut = $+[3];
$char += $1 ? 0 : $2 ? length $2 : length $3;
####
$char > $width and return substr( $string, 0, $cut, ''), $string;
}
return $string, '';
}
####
my $string2 = qq{01:11:43:09 [CC] Roger. Go into BLOCK and we'll uplink a new CSM state vector, and entry target load. 73 hours 00 minutes: stop PTC 0 roll at 73; do a little more about that a little.};
my $width = 91;
my $first_indent = 15;
my $next_indent = 15;
say "\n$string2\n";
say ta_wrap(
$string2, $width,
{ flindent => ' ' x $first_indent,
slindent => ' ' x $next_indent
}
);
01:11:43:09 [CC] Roger. Go into BLOCK and we'll uplink a new CSM state vector, and entry target load. 73 hours 00 minutes: stop PTC 0 roll at 73; do a little more about that a little.
Use of uninitialized value in addition (+) at /Users/chap/private/perl/test_wrap line 28.
01:11:43:09 [CC] Roger. Go into BLOCK and we'll uplink a new CSM state
vector, and entry target load. 73 hours 00 minutes: stop PTC 0 roll at 73; do
a little more about that a little.
####
String=<##
$char += $1 ? 0 : $2 ? length $2 : length $3;
####
$char += $1 ? 0 : defined $2 ? length $2 : length $3;