Hi all, Lets get back to the original question:
--- "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./; > } my answer: if (@array > $bound) { $array[$bound-1] = ", etc"; # Set element at boundary $#array = $bound-1; # Shorten array to boundary } print join ", ", @array; Now, this I *might* use in production code. Of course, the obvious mistake is that space between the last element and the ", etc" part - but easily solved by using .= to append to the appropriate element. E&OE Jonathan Paton ===== s''! v+v+v+v+ J r e P h+h+h+h+ !s`\x21`~`g,s`^ . | ~.*``mg,$v=q. P ! v-v-v-v- u l r e r h-h-h- !12.,@.=m`.`g;do{$.=$2.$1,$.=~s`h E ! v+v+v+ s k e h+h+ !`2`x,$.=~s`v`31`,print$.[$v+=$.] R ! v-v- t H a c h h- !}while/([hv])([+-])/g;print"\xA" L ! A n o t !';$..=$1while/([^!]*)$/mg;eval$. __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com