> > > join ', ', @array[0 .. $bound], @array > $bound ? 'etc' : (); > > > > No, it's not. In my way the effects on the array are > > permanent, although that's probably not useful in this > > instance > > Point taken. > > @array = @array[0 .. $bound], @array > $bound ? 'etc' : (); > join ', ', @array; > > :-) > > > $#array # Gives last index of array, can be assigned to > > # which increases or decreases the number of > > # elements. > > > > They didn't learn anything like that from yours... did they? ;-) > > @array[$min .. $max] # returns a list with all the elements > # between and including $array[$min] > # and $arrax[max] > > You don't want to challenge me to nitpicking ;-P
You mean like the original poster wanted 90 chars, not 90 elements? The text said: "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." but, the code said: $str = join ', ', @names; if (length($str)>90) { ($str = substr($str,0,90)) =~ s/,[^,]*$/, etc./; } So, when in doubt... which do you believe? "Use the source Luke" springs to mind. My fix is to repair the text with: s/list g/line length g/; Now, looking at the original code it looks quite sensible for the task in hand. Wonder if anyone else in the string of posters noticed that... I'm too lazy to look back over the growing list of mail on this topic though. 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