oops sorry I've made mistake :( the correct one is:

@arr = qw( this is just a testtestetstett );
$res;
for( @arr )
  {
  $res .= "etc...,", last if length "$res$_" > 10;
  $res .= "$_,";
  }
chop( $res );
print "$res\n";

:)

P! Vladi.


On Thu, 21 Nov 2002 15:01:49 +0200
Vladi Belperchinov-Shabanski <[EMAIL PROTECTED]> wrote:

> 
> 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...
> 


-- 
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...

Attachment: msg02765/pgp00000.pgp
Description: PGP signature

Reply via email to