On Tue, May 28, 2013 at 5:31 PM, Tadeusz B.
[email protected]wrote:
irb(main):011:0> s="#$!"
=> “”
Something is broken. Does anyone know whats going on with this ?
As stated, #$… in a String will interpolate the $… In your case,
there
is a global variable $"
which it is trying to interpolate, so you
think
you’re ending the string, but really, that second quotation is part of
the
variable name (I assume this was all inherited from Perl). You would
need
to do “#$”" For whatever reason, this doesn’t work in irb, but it does
work
in a Ruby program: ruby -e ‘p “#$”"’
Anyway, to get around this, escape the hash so that it isn’t looked at
as
interpolating: ruby -e ‘p “#$”’
Also, this is not good
irb(main):008:0> s=(“xxxxxx…#$yyyyyyyyy”)
=> “xxxxxx…”
Again, just escape the hash
s= “xxxxxx…#$yyyyyyyyy”
Is there a fundamental problem with the Ruby parser ?
or is this just an isolated glitch ?
No, it’s just unintuitive.
On Wed, May 29, 2013 at 4:52 AM, Tadeusz B. [email protected]
wrote:
data=eval(text)
It just so happened that one of the data items contained “#$”.
My workaround for the moment is : data=eval(text.gsub("#",’\043’))
Any better suggestions ?
I don’t understand this, why do you want to eval “ABC\267#$”? It is not
valid Ruby (ignoring the nonsenical characters, it would mean ‘look up
the
constant ABC’, which is presumably not what you’re intending). Can you
give
examples of inputs and outputs?