tags:

views:

70

answers:

2

Ok this is not a biggier but in the interest of writing cleaner code?

IO.popen("Generate a list of files").readlines.each{|f_nl|
   f=f_nl.chomp
   # ...

} Namely is there someway to chomp the whole array in one fell swoop?

+7  A: 
IO.popen("Generate a list of files").readlines.map(&:chomp)
buru
+1  A: 
IO.read("something").split($/)

$/ is the separator string. IO.read closes the file after reading.

steenslag