in reply to truncating a line

use the substr() as an lvalue:
substr($str, 17) = '...' if length $str > 17;