Use substr. This will leave you with 5 characters:
$text='abcdefghijklmnopqrstuvwxyz';
$text=substr $text, 0, 5;
print "$text\n";
Output:
abcde
Bruno Veldeman wrote:
> Hi,
>
> 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
>
> Any sugestions?
>
> Bruno