use Text::Wrap; $Text::Wrap::columns = 100; my $truncated = (split /\n/, wrap("", "", $string))[0];