File Packing Ideas - FINAL

I’m not sure why you want to split data and chomp them. Why
not just:

  1. read data into a string (with compressing)
  2. send cgi.escape(string) or string.dump


Nobu Nakada

I did not see anything on reading an entire file straight into a string. I
did find that readlines makes each line an array element. I am very
curious how you read a whole file into a string…?

Thanks,
Mike

I did not see anything on reading an entire file straight into a string. I
*did* find that readlines makes each line an array element. I am very
curious how you read a whole file into a string...?

pigeon% cat b.rb
#!/usr/bin/ruby
p IO.readlines('b.rb', nil)[0]
pigeon%

pigeon% b.rb
"#!/usr/bin/ruby\np IO.readlines('b.rb', nil)[0]\n"
pigeon%

Guy Decoux

s = File.open(‘file.txt’) {|f| f.read}

If I’m not mistaken 1.7 allows you this shortcut:

s = File.read('file.txt')

Massimiliano

···

On Thu, Nov 14, 2002 at 11:56:39PM +0900, Vera, Michael wrote:

I did not see anything on reading an entire file straight into a string. I
did find that readlines makes each line an array element. I am very
curious how you read a whole file into a string…?