From: David Douthitt Date: 2000-03-15T16:12:01-06:00 Subject: [ruby-talk:01869] Re: Another question from a newbie Whoops, wrong version........... I have a couple of ruby "programs" (embedded in ksh functions) that do almost the same thing.... ruby <<'!*' class String def comment? self =~ /^(#| *$)/ end end File.open(ENV["ORACONF"]) { |conf| conf.readlines.each { |line| next if comment? line.chomp! instance, days, cm, backup = line.split(":") if ((line =~ /^#{ENV["INST"]}/) && (cm == "Y")) then exit(1) end } } !* >>> Dave Thomas 03/15/00 03:50PM >>> "David Douthitt" writes: > Why not use this pattern substitution (instead of gsub! and yield) - > > line = s/[ \t]*#.*$//; > next if /^$/; > > Not sure how that translates to Ruby.... The s/// is a sub(/\s*#.*/, ''). The only reason for the separate method is reusability: the next time you need to read an Oracle configuration or whatever you've got the useful configReader method in your toolkit. > Here's the entire code, including invocation from ksh: I just ran this without error on my box. However, wasn;t it the version with comment? that was giving you a problem? Regards Dave