Problem with "here" document in hash constructor?

In the following code example, constructing hash1 works fine,
but constructing hash2 gives me a hash with only one key:

···

###########################################################
hash1 = {
    "key1" => "value1" ,
    "key2" => "value2"
}

p hash1
p hash1.keys.length

hash2 = {
"key1" => <<EOF
value1
EOF,
"key2" => <<EOF
value2
EOF
}

p hash2
p hash2.keys.length
########################################################

If I move the comma separating the two key/value pairs
to its own line (so that EOF is recognized properly), I get
a syntax error:

T2.rb:17: syntax error
T2.rb:18: warning: useless use of a literal in void context
T2.rb:18: syntax error
"key2" => <<EOF
         ^

Is there any way to do this using "here" documents (<<EOF)
and the Hash {} constructor style? I know I can do it by
constructing the hash another way, but...

Thanks,

JA

hash2 = {

  "key1" => <<EOF,

value1
EOF

  "key2" => <<EOF,

value2
EOF
}

-austin

···

On Apr 7, 2005 12:29 PM, john_b_andrews@yahoo.com <john_b_andrews@yahoo.com> wrote:
--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

In the following code example, constructing hash1 works fine,
but constructing hash2 gives me a hash with only one key:

[snip working example]

hash2 = {
"key1" => <<EOF
value1
EOF,
"key2" => <<EOF
value2
EOF
}

Try changing that too:

hash2 = {
"key1" => <<EOF,
value1
EOF
"key2" => <<EOF
value2
EOF
}

Hope that helps.

James Edward Gray II

···

On Apr 7, 2005, at 11:29 AM, john_b_andrews@yahoo.com wrote:

"Austin Ziegler" <halostatue@gmail.com> schrieb im Newsbeitrag news:9e7db911050407093655ee90aa@mail.gmail.com...

···

On Apr 7, 2005 12:29 PM, john_b_andrews@yahoo.com > <john_b_andrews@yahoo.com> wrote:

hash2 = {

"key1" => <<EOF,

value1
EOF

"key2" => <<EOF,

value2
EOF
}

Plus a bit of explanation / mnemonic: the "<<EOF" is the expression that's replaced by the here document. That's why you want the "," directly after "<<EOF".

Kind regards

    robert