On Tue, Nov 19, 2002 at 06:50:36PM -0500, Selector, Lev Y wrote:
> 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./;
>       }

        $str = substr(join(', ', @names), 0, 90);
        $str =~ s/,[^,]*$/, etc.../ if length $str >= 90;

which is basicaly what you've got, just restructured a bit.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
local $variable for local @people;

Reply via email to