--- "A. Pagaltzis" <[EMAIL PROTECTED]> wrote:
> * Steven Lembark <[EMAIL PROTECTED]> [2002-11-20 21:45]:
> > > but, the code said:
> > >
> > >     $str = join ', ', @names;
> > >         if (length($str)>90) {
> > >             ($str = substr($str,0,90)) =~ s/,[^,]*$/, etc./;
> > >         }
> > 
> > Original doesn't mention if the "etc." should fall w/in
> > the 90 char's or not. In that case you'd have to use a
> > length for the substr that leaves room for the trailer.
> 
> Noone paid attention, but it does. Look harder, it's there.
> (Solution: it does count toward the 90 char limit.)

I'm struggling to see why, can you enlighten me?  I understand
this:

    ($str = substr($str,0,90)) =~ s/,[^,]*$/, etc./;

Is a short hand for:

     $temp = substr($str, 0, 90);
     $temp =~ s/,[^,]*$/, etc./;
     $str = $temp;

or, in words... the substitution occurs en passant -
meaning that if you take 90 chars, and a comma is
the last character then the substitution ADDS
characters onto the string past char 90.

Thus, I stand to learn something if I'm wrong.  My
test code of:

my $str = ",";
($str = substr($str,0,1)) =~ s/,[^,]*$/, etc./;
print $str;

prints:

, etc.

which matches my understanding, and thus I'm extremely
interested to see your response.  Solution: It doesn't.

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

Reply via email to