use Text::Wrap qw(wrap $columns); $columns = 45; my @lines = wrap('', '', 'Make sure this string is 45 chars or less, and if you have to truncate it to make it shorter, only break it between a word (\s)'); print @lines;