Hi -- On Fri, 6 Jul 2007, Ari Brown wrote: > Ok. I have a major pattern matching problem. In essence, right now the word i > am trying to match is "hello", WITH double quotes around it. > > Why isn't this working? It always hits the else part of my case-when loop. > > write_file = open('albuminfo.txt', 'w') > lines.each do |line| > puts line > case line > when line =~ /^(.+)$/ > write_file.puts('"#{$1}"') > write_file.close > print '.' > else > print '$' > end > end > > It doesn't want to match! You're using case/when wrong. You've got: case line when (some expression that is nil or an integer) .... So you're really saying: if (nil or integer) === line You can either use a base case: case when line =~ /.../ or just use if/else, which to me seems more straightforward here. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)