- or download this
if( length($string) > 0 ) {
# do something
}
- or download this
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 );
}
- or download this
my $MAXLEN = 50;
if( length($string) > $MAXLEN ) {
# cut the string and either add ... to show it was truncated.
...
# alternatively, or not
$string = substr( $string, 0, $MAXLEN );
}