On 2002.05.09, Jim Freeze <jim / freeze.org> wrote:
> They are close, but splitting on \n is asking for trouble.
> Is there a better way to do this?

Is this cheating:

$ ruby -pe '' filename.txt

$ cat filename.txt | ruby -pe ''

;-)

You want to suck the entire contents of the file into
an array?  What's wrong with using $< like someone
else suggested:

$ cat feh.rb
p $<.readlines

$ cat feh.rb | ruby feh.rb
["p $<.readlines\n"]

$ ruby feh.rb feh.rb
["p $<.readlines\n"]

$ ruby feh.rb < feh.rb
["p $<.readlines\n"]

-- Dossy

-- 
Dossy Shiobara                       mail: dossy / panoptic.com 
Panoptic Computer Network             web: http://www.panoptic.com/ 
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)