use constant MAX_CHARS => 1100; if ( length($str) > MAX_CHARS ) { $str = substr( $str, 0, MAX_CHARS ); } #### # Limit the string's length $str = substr( $str, 0, MAX_CHARS );