Want to create a file with variable name

hi i want to create a file name, with that variable name..

for example..

a=10

f=File.open('a.txt','a')
created file name is a.txt
but
i want the file as 10.txt

can any one help??

···

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

Try:

f = File.open("#{a}.txt",'a')

Regards, John.

···

On 12/12/2008, Srikanth Jeeva <sri.jjhero@gmail.com> wrote:

hi i want to create a file name, with that variable name..

for example..

a=10

f=File.open('a.txt','a')
created file name is a.txt
but
i want the file as 10.txt

can any one help??
--
Posted via http://www.ruby-forum.com/\.

John Slobbe wrote:

Try:

f = File.open("#{a}.txt",'a')

Regards, John.

Thank You so much john..
its working.

···

--
Posted via http://www.ruby-forum.com/\.