http://qs321.pair.com?node_id=11135749


in reply to Creating an abstract

succinct - sort of, better - ???

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11135746 use warnings; use Data::Dump 'dd'; local $_ = 'text <one 1> three <two 2> four <five 5> K <six 6> lastwor +d'; for my $len ( 30 .. length ) { my $text = s/^.{0,$len}\b\K.*//sr =~ s/<[^<>]*\z//sr . '...'; dd $text; }

Outputs:

"text <one 1> three <two 2> ..." "text <one 1> three <two 2> four..." "text <one 1> three <two 2> four..." "text <one 1> three <two 2> four ..." "text <one 1> three <two 2> four ..." "text <one 1> three <two 2> four ..." "text <one 1> three <two 2> four ..." "text <one 1> three <two 2> four ..." "text <one 1> three <two 2> four ..." "text <one 1> three <two 2> four ..." "text <one 1> three <two 2> four ..." "text <one 1> three <two 2> four <five 5> ..." "text <one 1> three <two 2> four <five 5> K..." "text <one 1> three <two 2> four <five 5> K..." "text <one 1> three <two 2> four <five 5> K ..." "text <one 1> three <two 2> four <five 5> K ..." "text <one 1> three <two 2> four <five 5> K ..." "text <one 1> three <two 2> four <five 5> K ..." "text <one 1> three <two 2> four <five 5> K ..." "text <one 1> three <two 2> four <five 5> K ..." "text <one 1> three <two 2> four <five 5> K ..." "text <one 1> three <two 2> four <five 5> K <six 6> ..." "text <one 1> three <two 2> four <five 5> K <six 6> ..." "text <one 1> three <two 2> four <five 5> K <six 6> ..." "text <one 1> three <two 2> four <five 5> K <six 6> ..." "text <one 1> three <two 2> four <five 5> K <six 6> ..." "text <one 1> three <two 2> four <five 5> K <six 6> ..." "text <one 1> three <two 2> four <five 5> K <six 6> ..." "text <one 1> three <two 2> four <five 5> K <six 6> ..." "text <one 1> three <two 2> four <five 5> K <six 6> lastword..."