From: Richard Date: 2007-01-26T03:40:11+09:00 Subject: Problem using back-ticks + eval Hi, I'm trying to demo how Ruby handles various argument formats. For example, I write the statement: show %@`ruby DisplayArgs.rb Arg1 Arg2`@ and I get the output: `ruby DisplayArgs.rb Arg1 Arg2` => Arg[1]: "Arg1" Arg[2]: "Arg2" I'd like avoid having the back-ticks appear in the output. I'd like to achieve this by moving the back-ticks from show invocation to show's definition. In the following code, comments indicate what I tried, but it failed. Any ideas? Thanks in Advance, Richard # ShowCmdLineArgs.rb def show(stmt) print stmt puts "\n=> " eval("puts " + stmt).inspect # Put back-ticks around "stmt"? puts end puts "\n========= Examples =========" show %@`ruby DisplayArgs.rb Arg1 Arg2`@ show %@`ruby DisplayArgs.rb "Embedded "" quotes"`@ # Remove back-ticks from this? # DisplayArgs.rb MAXARGS = 10 puts "No arguments" unless ARGV[0] (0...MAXARGS).each { |i| break unless ARGV[i] print "Arg[#{(i+1).to_s}]: " puts ARGV[i].inspect puts "Quitting without inspecting addition arguments, if any!" if i == MAXARGS-1 }