# Script running in Ruby version 1.6.7 but not in 1.8.4

**URL:** <https://www.ruby-forum.com/t/script-running-in-ruby-version-1-6-7-but-not-in-1-8-4/61348>\
**Category:** Ruby\
**Created:** [May 23, 2006, 11:58am UTC](https://www.ruby-forum.com/t/script-running-in-ruby-version-1-6-7-but-not-in-1-8-4/61348 "2006-05-23T11:58:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 23, 2006, 11:58am UTC](https://www.ruby-forum.com/t/script-running-in-ruby-version-1-6-7-but-not-in-1-8-4/61348/1 "2006-05-23T11:58:15Z")

</div>

Hi,

I have written a script in Ruby version 1.6.7 running in Windows and it  
is  
doing fine. But when I start it in Linux with Ruby version 1.8.4 there  
are  
lot of error messages.

I minimized the script to that part, which will cause the errors.

Here it is:

* * *

#======================================================================

# class Block

# 

# Block

# =====================================================================

class Block

UMLAUTE = “”\<\<0x84\<\<0x81\<\<0x94\<\<0x80\<\<0x99\<\<0x9A\<\<0xE1  
REG\_VAR\_NAME = “[a-z]+[a-z0-9\_#$”+"()" + “@.” + UMLAUTE + “]_"  
REG\_PLAIN\_NAME = “[a-z]+[a-z0-9\_” + “.” + UMLAUTE + "]_”  
REG\_PARAM\_LIST = “[a-z]+[a-z0-9\_#$,” + UMLAUTE + “]_"  
REG\_STRUCT\_NAME = “[a-z]+[a-z0-9\_” + UMLAUTE + "]_”

#--------------------------------------------------------------------

# Block#adapt\_param\_list\_with\_types

# 

# Change paramlist for use in c++ prototypes

#--------------------------------------------------------------------  
def adapt\_param\_list\_with\_types(var\_list)  
out\_list = String.new("")  
vars = var\_list.split(’,’)

```
vars.each do |var|
  if var =~ /REF/
    ref = "&"
  else
    ref = ""
  end
  case var
    when Regexp.new("REF\s(#{REG_PLAIN_NAME)

```

[@]\sOF\s(#{REG\_PLAIN\_NAME})$")  
out\_list += “#{$2} \*#{$1},”  
when Regexp.new("(#{REG\_PLAIN\_NAME})#$")  
out\_list += “int " + ref + $1 + “\_int,”  
when Regexp.new(”(#{REG\_PLAIN\_NAME})[$]$")  
out\_list += “str " + ref + $1 + “\_str,”  
when Regexp.new(”(#{REG\_PLAIN\_NAME})$")  
out\_list += "double " + ref + $1 + “,”  
else  
out\_list += var + “,”  
end  
end  
out\_list.chop!  
#puts "var\_list = " + var\_list  
#puts "out\_list = " + out\_list  
return adapt\_umlaut\_in\_var\_names(out\_list)  
end

end

* * *

Here are the error messages:

* * *

ruby test.rb

test.rb:9: parse error, unexpected ‘(’, expecting kEND  
REG\_VAR\_NAME = “[a-z]+[a-z0-9\_#$”+"()" + “@.” + UMLAUTE + “]_"  
^  
test.rb:9: parse error, unexpected $undefined., expecting kEND  
REG\_VAR\_NAME = “[a-z]+[a-z0-9\_#$”+"()" + “@.” + UMLAUTE + "]_”  
^  
test.rb:9: parse error, unexpected ‘]’, expecting kEND  
REG\_VAR\_NAME = “[a-z]+[a-z0-9\_#$”+"()" + “@.” + UMLAUTE + “]_"  
^  
test.rb:10: trailing `_' in number REG_PLAIN_NAME = "[a-z]+[a-z0-9_" + "." + UMLAUTE + "]*" ^ test.rb:10: parse error, unexpected tSTRING_BEG, expecting ']' REG_PLAIN_NAME = "[a-z]+[a-z0-9_" + "." + UMLAUTE + "]*" ^ test.rb:10: parse error, unexpected tSTRING_BEG REG_PLAIN_NAME = "[a-z]+[a-z0-9_" + "." + UMLAUTE + "]*" ^ test.rb:10: parse error, unexpected ']', expecting kEND REG_PLAIN_NAME = "[a-z]+[a-z0-9_" + "." + UMLAUTE + "]*" ^ test.rb:11: trailing`’ in number  
REG\_PARAM\_LIST = "[a-z]+[a-z0-9#$," + UMLAUTE + "]_”  
^  
test.rb:12: parse error, unexpected tCONSTANT, expecting ‘]’  
REG\_STRUCT\_NAME = “[a-z]+[a-z0-9\_” + UMLAUTE + “]\*”  
^  
test.rb:33: parse error, unexpected tIDENTIFIER, expecting ‘)’  
out\_list += “int " + ref + $1 + “\_int,”  
^  
test.rb:33: parse error, unexpected tIDENTIFIER, expecting kEND  
out\_list += “int " + ref + $1 + “\_int,”  
^  
test.rb:34: parse error, unexpected ‘(’, expecting tCOLON2 or ‘[’ or ‘.’  
when Regexp.new(”(#{REG\_PLAIN\_NAME})[$]$”)  
^  
test.rb:36: parse error, unexpected kWHEN, expecting kEND  
when Regexp.new("(#{REG\_PLAIN\_NAME})$")  
^  
test.rb:38: parse error, unexpected kELSE, expecting kEND  
else  
^  
test.rb:48: parse error, unexpected kEND, expecting $

* * *

Does anybody have an idea, why these erorr messages occur?

Siegward

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 23, 2006, 12:07pm UTC](https://www.ruby-forum.com/t/script-running-in-ruby-version-1-6-7-but-not-in-1-8-4/61348/2 "2006-05-23T12:07:26Z")

</div>

> > > > > “B” == Beratung [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

Write it like this

B\> class Block

B\> UMLAUTE = “”\<\<0x84\<\<0x81\<\<0x94\<\<0x80\<\<0x99\<\<0x9A\<\<0xE1  
B\> REG\_VAR\_NAME = “[a-z]+[a-z0-9\_#$”+“()” + “@.” + UMLAUTE + “]\*”

```
 REG_VAR_NAME = "[a-z]+[a-z0-9_$#"+"()" + "@." + UMLAUTE + "]*"

```

B\> REG\_PLAIN\_NAME = “[a-z]+[a-z0-9\_” + “.” + UMLAUTE + “]_"  
B\> REG\_PARAM\_LIST = “[a-z]+[a-z0-9\_#$,” + UMLAUTE + "]_”

```
 REG_PARAM_LIST = "[a-z]+[a-z0-9_$#," + UMLAUTE + "]*"

```

otherwise it try to interpret

#$" as #{$"}

#$, as #{$,}

B\> REG\_STRUCT\_NAME = “[a-z]+[a-z0-9\_” + UMLAUTE + “]\*”

Guy Decoux

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 23, 2006, 12:13pm UTC](https://www.ruby-forum.com/t/script-running-in-ruby-version-1-6-7-but-not-in-1-8-4/61348/3 "2006-05-23T12:13:36Z")

</div>

Hi –

On Tue, 23 May 2006, removed\_email\_address@domain.invalid wrote:

> * * *
> 
> #======================================================================
> 
> # class Block
> 
> # 
> 
> # Block
> 
> # =====================================================================
> 
> class Block
> 
> UMLAUTE = “”\<\<0x84\<\<0x81\<\<0x94\<\<0x80\<\<0x99\<\<0x9A\<\<0xE1  
> REG\_VAR\_NAME = “[a-z]+[a-z0-9\_#$”+"()" + “@.” + UMLAUTE + “]\*”

In 1.8.4, you can use the shorthand of #$x for #{$x} with global  
variables. So Ruby thinks you want to interpolate the variable $".  
The " therefore doesn’t count as a string delimiter, and you get in  
trouble.

If you escape the # (#) it should be OK.

David

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 23, 2006, 12:41pm UTC](https://www.ruby-forum.com/t/script-running-in-ruby-version-1-6-7-but-not-in-1-8-4/61348/4 "2006-05-23T12:41:37Z")

</div>

Thank you. I changed double quotes into single quotes and now it’s  
working  
fine.

Siegward
