Help for this page

Select Code to Download


  1. or download this
    sub trim_length {
       my ( $str, $desired_len ) = @_;
       $str =~ s/\s+$//; # Strip trailing whitespace
    ...
       return sprintf "%.${desired_len}s ...", 
          substr $str, 0, ( rindex $str, ' ', $desired_len );
    }