From: zuerrong Date: 2010-12-09T10:55:53+09:00 Subject: Re: identifying and removing comments in a seprate ruby file I wrote a simple one, maybe that's not so good. $ cat 1.rb # this is a comment arr = [1,2,3,4] # now loop through the array arr.each {|s| puts s } =begin author: somebody else date: 2010-12-12 =end $ cat rmcomm.rb lab=0 File.open("1.rb").each_line do |s| next if s=~/^#|^$/ if s=~/^=begin/ lab = 1 elsif s=~/^=end/ lab = 0 next end next if lab == 1 puts s end $ ruby rmcomm.rb arr = [1,2,3,4] arr.each {|s| puts s } 2010/12/9 Robhy B. : > Hi everyone, > > I'm working on a ruby program that's supposed to find and remove single > line comments starting with "#" and block comments starting with > "=begin" and finishing with "=end" from a separate ruby source file. I'm > having trouble with this assignment can anyone help? > > Thanks > > -- > Posted via http://www.ruby-forum.com/. > >