From: Jack Dempsey Date: 2002-01-12T13:01:55+09:00 Subject: RE: Another suggestion for FreeRIDE Here's the code for that: easy, but it'll do the subs...i left the outputting of "require english.rb" to the end user... #!/usr/bin/ruby text = 'this is some text that uses variables like $!, $;, $=, and $0.' hash_map = { '$!' => '$ERROR_INFO', '$@' => '$ERROR_POSITION', '$"' => '$LOADED_FEATURES', '$;' => '$FS', '$;' => '$FIELD_SEPARATOR', '$,' => '$OFS', '$,' => '$OUTPUT_FIELD_SEPARATOR', '$/' => '$RS', '$/' => '$INPUT_RECORD_SEPARATOR', '$\\' => '$ORS', '$\\' => '$OUPUT_RECORD_SEPARATOR', '$.' => '$INPUT_LINE_NUMBER', '$.' => '$NR', '$_' => '$LAST_READ_LINE', '$>' => '$DEFAULT_OUTPUT', '$<' => '$DEFAULT_INPUT', '$$' => '$PID', '$$' => '$PROCESS_ID', '$?' => '$CHILD_STATUS', '$~' => '$LAST_MATCH_INFO', '$=' => '$IGNORECASE', '$0' => '$PROGRAM_NAME', '$*' => '$ARGV', '$&' => '$MATCH', '$`' => '$PREMATCH', "$'" => '$POSTMATCH', '$+' => '$LAST_PAREN_MATCH' } puts text hash_map.each { |k,v| text.gsub!(Regexp.escape(k),v) } puts text Jack -----Original Message----- From: Phil Tomson [mailto:ptkwt@shell1.aracnet.com] Sent: Friday, January 11, 2002 10:26 PM To: ruby-talk ML; undisclosed-recipients: Subject: Another suggestion for FreeRIDE Based on some discussions over at comp.lang.python... Someone raised the issue of Ruby's borrowing the predefined variables like $:, $!, $? and their ilk from Perl. I suggested that you can require english.rb so that you can use more comprehensible names for these variables. The Python person objected saying that he didn't like the fact that someone else might use the unreadable ones in code that he might have to read. Which gave me an idea: What if you have an optional setting in FreeRIDE so that if you read in a file with the unreadable predefined variables they get automatically replaced with their equivilents defined in english.rb (and the line: 'require "english.rb"' get's appended to the top of the file). That way if you don't want to deal with looking up the various unreadable (incomprehensible) predefined vars. Phil