in reply to 30 Spaces- 1 question

tr is not the right tool here.

if ($desc =~ m#((?:\S+\s*){1,30})#) { $first_30 = $1; } else { # Didn't match here }

-dlc