my $MyPrtVar = $var;
if ( length($var) > 8 ) {
   $MyPrtVar = substr($var,0,8) . '...';
 }

Wags ;)

-----Original Message-----
From: Bruno Veldeman [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 06, 2001 12:16
To: [EMAIL PROTECTED]
Subject: How to truncate a string?


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

Reply via email to