hi, my no golf, join, map, RE solution is: :)
@arr = qw( this is just a test );
$res;
for( @arr )
{
$res .= "$_,";
$res .= "etc...,", last if length $res > 10;
}
chop( $res );
print "$res\n";
the number 10 is matter of taste, 90 could be nice figure also...
P! Vladi.
On Tue, 19 Nov 2002 18:50:36 -0500
"Selector, Lev Y" <[EMAIL PROTECTED]> wrote:
> Folks,
>
> Simple question:
> Is there a more elegant way to express this:
> an array of names is converted into a comma-separated list.
> if the list gets to long - limit it and add ", etc." at the end.
>
> $str = join ', ', @names;
> if (length($str)>90) {
> ($str = substr($str,0,90)) =~ s/,[^,]*$/, etc./;
> }
>
> Warmest Regards,
> Lev Selector, New York
>
--
Vladi Belperchinov-Shabanski <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
Personal home page at http://www.biscom.net/~cade
DataMax Ltd. http://www.datamax.bg
Too many hopes and dreams won't see the light...
msg02734/pgp00000.pgp
Description: PGP signature
