if( length($string) > 0 ) { # do something } #### if( length($string) > 50 ) { # cut the string and either add ... to show it was truncated. $string = substr( $string, 0, 47 ) . '...'; # alternatively, or not $string = substr( $string, 0, 50 ); } #### my $MAXLEN = 50; if( length($string) > $MAXLEN ) { # cut the string and either add ... to show it was truncated. $string = substr( $string, 0, $MAXLEN-3 ) . '...'; # alternatively, or not $string = substr( $string, 0, $MAXLEN ); }