From: James Edward Gray II Date: 2005-07-29T04:04:01+09:00 Subject: Re: Hash and multiline items Yannick Turgeon wrote: > Hello, > > I'm a newbie and I wanted to get a hash with items having > multilines string. > Something like this (air coded) : > > SQL = { > "Company" => <<-END_SQL > SELECT Name > FROM Company > WHERE Active = 1 > END_SQL > , > "Employee" => <<-END_SQL > SELECT Name, Title > FROM Employee > WHERE Active = 1 > END_SQL > } You just need to move the commas, they go after the heredoc declaration, not after the end of the heredoc. SQL = { "Company" => <<-END_SQL, SELECT Name FROM Company WHERE Active = 1 END_SQL "Employee" => <<-END_SQL, SELECT Name, Title FROM Employee WHERE Active = 1 END_SQL } You can even add calls to gsub() if you want to strip the leading whitespace: SQL = { "Company" => <<-END_SQL.gsub(/^\s+/, "").tr("\n", " "), SELECT Name FROM Company WHERE Active = 1 END_SQL "Employee" => <<-END_SQL.gsub(/^\s+/, "").tr("\n", " "), SELECT Name, Title FROM Employee WHERE Active = 1 END_SQL } Hope that helps. James Edward Gray II