module Argu attr_reader :lis def initialize @lis = Array.new end pro = '' def eval_stdin if ARGV.length > 0 if ARGV[0] == '-l' pro = `ls` @lis = pro.split(/\n/) elsif ARGV[0] == '-f' @lis = IO.readlines(ARGV[1]) else @lis = ARGV end else puts "No args given, exiting...\n" exit end end end ##So, using this module would be like this: ##(in your program) ## include Argu ## eval_stdin ## @lis.each{|f| ## #do something... ## } ## and you would run your program: ## prompt% ruby myprogram.rb -l ##this comes handy when you have, let's say, some thousands of text files in a ##directory and you would like your program to parse them.