require "pathname" ports = Pathname.glob("ports/archivers/*/").map { |i| i.basename.to_s } => ["arc", "blosc", "brotli", "bzip", "bzip2", "cabextract", "CVS", "deco", "deutex", "fastjar", "freeze", "fuse-zip", "gcab", "gcpio", "geteltorito", "gshar+gunshar", "gtar", "ha"] # Doesn't output DESCR from inside the loop ports.first do |port| file = File.read("ports/archivers/#{ port }/pkg/DESCR") end => "arc" # Outputs it fine from outside the loop file = File.read("ports/archivers/#{ ports.first }/pkg/DESCR") => "This package creates and extracts-from ARC archives. An ARC archive\ncontains files which are compressed according to the most efficient\nof three algorithms. ARC archives are usually only used for compatibility\nwith MS-DOS.\n"