From: Christian von Kleist Date: 2007-12-04T01:07:46+09:00 Subject: Re: read file and print contents - beginner I would change if $indent > 0 (1..$indent).each { print ' ' } end to print ' ' * $indent On Dec 3, 2007 10:57 AM, Johnathan Smith wrote: > hello, > > im new to ruby and i have a text file and want to read in the file > and print it out. > > so far iv got the following. I'd greatly appreciate any help. > > thanks. > > text file (reference.txt): > Tag: ref1 > Type: Book > Author: Little, S R > > ruby file: > #!/usr/local/bin/ruby > # > # > # read file and print > # > ARGV.each do |fn| > begin > (fn == '-' ? STDIN : File.open(fn)).each_line do |l| > if $indent > 0 > (1..$indent).each { print ' ' } > end > puts l > end > -- > Posted via http://www.ruby-forum.com/. > >