From: Richard Date: 2006-11-28T11:05:09+09:00 Subject: Re: Problem using #{...} in eval Hi John, Thank you very much. Now that you point out I need to escape those "pound signs", it makes sense. That enabled me to do what I *really* wanted to do: set a variable "n" to the number of significant digits wanted. The result (which doesn't address rounding, which I'll add): show(%Q@require 'bigdecimal' require 'bigdecimal/math' include BigMath n=20 BigMath::PI(n).to_s =~ /.(.)(.)(.{\#{n-1}})/ "result = " + "\#{$2}\#{$1}\#{$3}" @) Again, many thanks for your expert insight. Best wishes, Richard John W. Long wrote: > Richard wrote: > > #3: Can't find the elements of the match > > show(%Q@require 'bigdecimal' > > require 'bigdecimal/math' > > include BigMath > > BigMath::PI(6).to_s =~ /.(.)(.)(.{5})/ > > "result = " + "#{$2}#{$1}#{$3}" > > @) > > > You need to escape the # signs with a slash: > > show(%Q@require 'bigdecimal' > require 'bigdecimal/math' > include BigMath > BigMath::PI(6).to_s =~ /.(.)(.)(.{5})/ > "result = " + "\#{$2}\#{$1}\#{$3}" > @) > > -- > John Long > http://wiseheartdesign.com