From: Dossy Date: 2003-02-06T20:45:16+09:00 Subject: Re: %L, %l revisited On 2003.02.06, Tom Sawyer wrote: > > that is an good use of HERE docs. i did not know you could embed them in > methods until i ran this. that's useful. i like them more now. You ought to read this very well-written article on here-docs, written by Randal Schwartz: Unix Review Column 12 (January 1997) http://www.stonehenge.com/merlyn/UnixReview/col12.html My personal favorite and not commonly known feature of here-docs: irb(main):015:0> puts <<`SHELL` irb(main):016:0` for i in *; do irb(main):017:0` echo $i irb(main):018:0` done irb(main):019:0` SHELL [..my files snipped..] nil > for myself i think i'd still lean toward assigning variables to pass > into the method for clearity, Here-docs improve clarity, usually. > > anyway. Shell scripting languages already have it before there was > > perl. But, I do not know if it originated from sh or something even > > more ancient. > > really, that old? Yes, that old. The Traditional Bourne Shell Family http://www.uni-ulm.de/~s_smasch/bourne/ This page links to Version 7's Bourne shell manpage (supposedly from 1979) which documents here-docs (without calling them here-docs way back when) like so: < p <<-"EOT" irb(main):002:0" this is irb(main):003:0" a test irb(main):004:0" EOT "\tthis is\n\ta test\n" nil I'm generating the tabs using ^V^I in irb ... at least Ruby parsed it as a here-doc, even if it didn't strip the tabs ... -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)