[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

unexpected kEND, expecting $

Comfort Eagle

11/23/2006 9:06:00 PM

a = IO.readlines('testparsed')

a.each do |groupname|
filename = groupname.chomp
File.open filename
puts data
end
end

Why does this give me: "parse error, unexpected kEND, expecting $" for
the line with the last 'end'?

--
Posted via http://www.ruby-....

3 Answers

Farrel Lifson

11/23/2006 9:11:00 PM

0

On 23/11/06, Comfort Eagle <steve@fooworks.com> wrote:
> a = IO.readlines('testparsed')
>
> a.each do |groupname|
> filename = groupname.chomp
> File.open filename
> puts data
> end
> end
>
> Why does this give me: "parse error, unexpected kEND, expecting $" for
> the line with the last 'end'?
>
> --
> Posted via http://www.ruby-....
>
>

File.open filename do

Farrel

Jano Svitok

11/23/2006 10:32:00 PM

0

On 11/23/06, Comfort Eagle <steve@fooworks.com> wrote:
> a = IO.readlines('testparsed')
>
> a.each do |groupname|
> filename = groupname.chomp
- File.open filename
+ File.open filename do |file|
- puts data
+ file.puts data # if writing to file is what want to do
> end
> end

Paul Lutus

11/24/2006 6:25:00 AM

0

Comfort Eagle wrote:

> a = IO.readlines('testparsed')
>
> a.each do |groupname|
> filename = groupname.chomp
> File.open filename
> puts data
> end
> end
>
> Why does this give me: "parse error, unexpected kEND, expecting $" for
> the line with the last 'end'?
>

a.each do |groupname|
File.open(groupname.chomp,"w") { |f| f.write data }
end

--
Paul Lutus
http://www.ara...