execution problem in ruby

P

Pokkai Dokkai

how to execute a ruby program which is inside a string ?
for example
ex.rb

puts "start "
temp="(1..10).each do |count| print count end "
puts "end"


how to execute the source code in temp(String object)
 
K

Konrad Meyer

--nextPart5254935.2pq4zl0mjA
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

how to execute a ruby program which is inside a string ?
for example
ex.rb
=20
puts "start "
temp=3D"(1..10).each do |count| print count end "
puts "end"
=20
=20
how to execute the source code in temp(String object)

eval(string), but this is always what NOT-WHAT-YOU-WANT-TO-DO.

=2D-=20
Konrad Meyer <[email protected]> http://konrad.sobertillnoon.com/

--nextPart5254935.2pq4zl0mjA
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBGvL1UCHB0oCiR2cwRAoFlAJ9vAWK4NYjPAqU0C8L5aH+TbsH3uwCbBRhH
M/uoPwqTUqjzWEO1oX8lVzI=
=udrY
-----END PGP SIGNATURE-----

--nextPart5254935.2pq4zl0mjA--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top