On 8/17/07, ashishwave <ashishwave / gmail.com> wrote:
> Hi,
> how to do heredoc without interpolation and backslashes interpretation
> with arbitrary delimiter support (not just a single character)
>
> let me explain my point:
>
>  # here #{var1} gets interpolated
>  puts <<EOL
>     hello #{var1}
>   EOL
>
>  #here interpolation is off, backslashes interpretation is off, but
> you have to delimit it insingle character {}  @@ !!    .If your
> heredoc string itself is very complex and contains all ASCII
> charcaters and combo of backslashes then it becomes unsuable.
>   puts %Q{
>        hello #var1
>   }
>
>   SOMETHING LIKE THIS SHOULD BE ADDED TO/POSSIBLE IN RUBY
>   #HERE NOTHING GETS INTERPOLATED AND backslashes also remain there.
>   puts %Q{<<EOLLLL
>     @#$%^%&%&%&%SFSFSV #{abc} #{que} \r\n
>     \n
>   EOLLLL
>   }
>
>   Many times i have lots of jumbled up patterns from h/w device
> responses or i want to embed binary/image files itself inside ruby
> source code, then i am not able to do it with interpolation (which
> creates problem for #{  occurence ) or with backslash interpretation
> and also if i try to do it with single character delimters like %Q and
> {} [] !! @@ combination THEN single character } or ! or @ etc are more
> likely to appear in binary string itself ; creating problems for me.
> So i need my own relevant custom arbitrary length delimiter (like
> EOLLLL here) with this too, which is lot less less likely to appear in
> the heredoced string than a single delimited character.
>
>  So how to do it?

http://www.zenspider.com/Languages/Ruby/QuickRef.html#8

Here Docs

<<identifier   - interpolated, goes until identifier
<<"identifier" - same thing
<<'identifier' - no interpolation
<<-identifier  - you can indent the identifier by using "-" in front