From: Jo Ay Date: 2008-04-14T07:29:32+09:00 Subject: Deleting first lines of Array Hi, I'm new to Ruby, and so I was trying some stuff I was used to do with ease in perl. Something like capturing and storing the output of a commandline app in an array and manipulate that array afterwards. After searching the net, I finally found the following solution (capture output, then slice unecessary stuff away). Unfortunately slicing doesn't work when i'm using open3 to capture the output. Question: what am I doing wrong? I attached the working code + the method I want to modify: Regards Joey ############################################################# #!/usr/bin/ruby class dpkg def initialize @InstalledPackageList = Array.new end def collect_inst_packages @InstalledPackageList = `/usr/bin/dpkg -l`.split( /\n/ ) @InstalledPackageList.slice!(0, 5) end def get_inst_packages(filter = "") @InstalledPackageList.grep(/#{filter}/) end def show_inst_packages(filter = "") puts @InstalledPackageList.grep(/#{filter}/) end end ax = dpkg.new ax.collect_inst_packages ax.show_inst_packages(ARGV[0]) ############################################################# # new method, that I want to use (but I also need to delete # the first 5 lines of the dpkg output def collect_inst_packages require 'open3' stdin, @InstalledPackageList, stderr = Open3.popen3("/usr/bin/dpkg -l") # cut away the first 5 lines end ############################################################# -- Posted via http://www.ruby-forum.com/.