Help for this page

Select Code to Download


  1. or download this
    sub trunc
    {
    ...
        @tokens = split /\s+/, $text;
        return join " ", @tokens[0..$last_word-1];
    }
    
  2. or download this
        @tokens = split /(\s+)/, $text, -1;  # keep all white-space
        my $trunc_str = '';
    ...
        }
        return $trunc_str;
    }