On Tuesday 19 November 2002 15:50, Selector, Lev Y wrote:
>
> 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 $len = 89;
my $str = join ', ', @names;
$str =~ s/(.{0,$len},).*/$1 etc./;
John
--
use Perl;
program
fulfillment
