Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > slurp a file into an array without newlines

Reply
Thread Tools

slurp a file into an array without newlines

 
 
Dick Davies
Guest
Posts: n/a
 
      09-29-2005
Coffee....not.....working.......

what's a neater way of doing this?

lines =3D File.new('sometextfile').readlines.map { |l| l.chomp }

--
Rasputin :: Jack of All Trades - Master of Nuns


 
Reply With Quote
 
 
 
 
Gavin Sinclair
Guest
Posts: n/a
 
      09-29-2005

Dick Davies wrote:
>
> what's a neater way of doing this?
>
> lines = File.new('sometextfile').readlines.map { |l| l.chomp }
>


require 'rio'

lines = rio('sometextfile').chomp.lines[]

Gavin

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File::Slurp/IO::String/wantarray interaction bug kj Perl Misc 7 06-15-2010 04:12 PM
Best way to slurp a file into a string? Wes Gamble Ruby 7 03-23-2006 10:34 PM
Slurp large files into an array, first is quick, rest are slow gdtrob@gmail.com Perl Misc 7 12-30-2005 02:04 AM
File slurp takes a long time on some files Tom Sliva Perl Misc 7 11-23-2004 06:12 PM
&read_file in File::Slurp terminates unexpectedly on file Charles R. Thompson Perl Misc 6 01-13-2004 04:00 PM



Advertisments