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?
If you're asking for help with homework, you'll probably get some help
if you show some of what you've done so far and/or what exactly you're
having trouble doing. For instance, are you having problems opening the
file, reading its contents, or identifying the contents of interest once
you read them? Is your program raising errors? If so, what errors?
-Jeremy
···
On 12/08/2010 07:31 PM, Robhy B. wrote:
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?
To answer your question, yes, there's lots of people that can help.
But no one likes doing homework for others. You'll get better results
if you show some effort to solve the problem and have a specific
question about some implementation detail.
Alex Stahl | Sr. Quality Engineer | hi5 Networks, Inc. | astahl@hi5.com
On Wed, 2010-12-08 at 19:31 -0600, Robhy B. wrote:
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?
$ 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
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?