On Wed, 6 Jun 2001, Bruno Veldeman wrote:

> I have been looking for a function to truncate a string at a given lenght, but am 
>lost.
>
> None of the functions seen to do this, I remember BASIC having A$ = 
>left$("1234567890",5).
> Does perl have this function?
>
> What I want is to cut off all strings at a given lenght if the string exeeds it, and 
>add ... to them so the user can see it was cut off.
>
> So blablablabla would be blablabl... if cut on 8th position

my $truncated = substr($str, 0, 8) . '...';

See the documentation on substr for more details.

-- Brett

Brett W. McCoy
Software Engineer
Broadsoft, Inc.
240-364-5225
[EMAIL PROTECTED]

Reply via email to