From: Robert Feldt Date: 2001-05-11T17:28:11+09:00 Subject: [ruby-talk:14986] Re: Eval to Proc? On Fri, 11 May 2001, Renald Buter wrote: > Hello, > Hi, > My question is: is it possible to create a Ruby block/proc for evaluating > using a string? > > For example > > #!/usr/local/ruby -w > # test.rb > p = Proc.new(ARGV[0]) > mbox.each { |mail| call p(mail) } > > using the command line: > > $ ruby test.rb '|mail| mail.get_from =~ /test header/ and puts mail' > > or something like that? > Yes (if I understand you correctly...), #!/usr/local/ruby -w # test.rb p = eval "proc{#{ARGV[0]}}" mbox.each &p Regards, Robert