From: angus Date: 2005-12-25T20:03:17+09:00 Subject: Re: convert perl code to ruby: help please [vnpenguin@gmail.com, 2005-12-25 11.02 CET] > I'm trying to do the same method in Ruby: > ---------------------------------------------------------------------- > charmap = { ... > "a^." => "\xe1\xba\xad"} > > def vconv (str) > str.gsub(/([aA] (?:[(^]?['`?~.]|[(^]) )/){ |k| charmap[k] } > end > $stdin.each {|line| puts vconv(line)} Hi, from vconv you cannot see charmap (different scopes). You can make charmap a constant (change the name to CHARMAP) or a global variable ($charmap). HTH