On Jan 26, 2007, at 7:35 PM, atraver / gmail.com wrote:

> a = 42
> eval <<-STR
>   puts "hi" if a =~ /\d{2}/
> STR

If you want this to write "hi" to stdout, it should be

a = "42"
eval <<'STR'
   puts "hi" if a =~ /\d{2}/
STR

Notes

1. the variable a must reference a string not a number.
2. single-quoting STR tells Ruby to use single-quote rules for the  
HERE doc.
3. the - after << is not needed since the final STR is not indented.

See the Pickaxe book Part III/Basic Types/Strings for more info.

Regards, Morton