Octavian Rasnita wrote:

> I have a string $line that can be a short word or a very long line,
> and I want to cut it if it is longer than 20 characters, then to end
> it with .... Is there any Perl function for chopping what is over a
> number of characters?

substr($string, $start, $length)

> For example I have a string:
> 
> $line = "Microsoft is a big company and I love Bill Gates";
> And I want to cut it to become:
> 
> $line = "Microsoft is a big...";

$line = substr($line, 0,  18) . "...";

Length of 20 goes to the c in company...

HTH

-- 
Bud Rogers  <[EMAIL PROTECTED]>   http://www.sirinet.net/~budr
All things in moderation.  And not too much moderation either.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to