On Thu, Nov 21, 2002 at 02:47:59AM +0100, A. Pagaltzis wrote:
> * Dave Arnold <[EMAIL PROTECTED]> [2002-11-21 02:45]:
> > $str = join ', ', @names;
> > if ( length($str) > 90 )
> > {
> > substr($str,rindex($str,",",90)) = ", etc.";
> > }
>
> Nice, and so obvious too - in retrospect, of course.
>
> The only thing I don't like about it is it still joins
> everything, even if it only needs 3 out of 10,000 elements.
Perhaps:
my $str = shift @names;
$str .= ', '.shift @names while 90 > length $str;
substr($str, rindex($str, ',', 90)) = ", etc." if 90 < length $str;
Paul
--
Paul Makepeace ....................................... http://paulm.com/
"What is the meaning of meaing? A female grizzly and her cub."
-- http://paulm.com/toys/surrealism/