a quick question: in perl, using $& hits your whole program with a
performance penalty...is it different in ruby?

> -----Original Message-----
> From: ts [mailto:decoux / moulon.inra.fr]
> Sent: Tuesday, January 29, 2002 12:50 PM
> To: ruby-talk ML
> Cc: ruby-talk / ruby-lang.org
> Subject: Re: newbie help String#method!
>
>
> >>>>> "L" == Larry Forrister <L4 / stetson.net> writes:
>
> L> How do you create an in place modification method based on or
> equivalent to the
> L> one listed below?  i.e.... proper_case!
>
>  Well, there are many ways. A stupid one is
>
>    class String
>        def proper_case
>           dup.proper_case!
>        end
>
>        def proper_case!
>           @pc=' '
>           @rs=''
>           i = 0
>           self.each_byte{|@ib|
>              @ic=@ib.chr
>              if @pc==' '
>                 self[i] = @ic.upcase
>              end
>              @pc=@ic
>              i += 1
>           }
>           self
>        end
>    end
>
>
> p.s.:
>
>     string.gsub(/(?:^| )\w/) { $&.upcase }
>
>
> Guy Decoux
>