From: Tom Sawyer Date: 2003-02-07T03:37:42+09:00 Subject: Re: %L, %l revisited On Thursday 06 February 2003 11:10 am, Tom Sawyer wrote: > [ruby-talk:50473]. In his idea, if you assign a character (except > quotes) after the here-document indicator "<<-", All blanks and > assigned character at the head of each line will be deleted. > Here is a example assigning '|': > > p <<-|EOS > > | foo > | bar > > EOS > # => " foo\n bar\n". > a number of suggestions were made at this point (many incompatible with > current here docs). the most important point though was probably that the > deliminator should be redefinable. but no specific solution was derived for > this. my mistake, assigning character was built in. i think this was generally over looked. great! i think that gives us this: A NEW HERE DOCUMENT FORM PROVIDING MARGIN CONTROL: p <<-:EOS :#{foo} :example EOS all here variants work, ex- p <<)'EOS' )foo )example EOS ADDITIONALLY A NEW COMPLIMENTRY DELIMITED INPUT: p %L|#{foo} |example and provides likewise for the variances, ex- p %l)foo )example potential additional suggestions: the construct can be termintated with the deliminator to be able to apply methods to it: p %l)foo )example).upcase further the %L, %l delimited input can be terminated per-line and have per-line aggregating method calls: p %L|#{foo}| << ' bar' |example|.upcase if possible, there could be two forms of this. perhaps %A, %a for the above and instead use %L, %l for a non-aggregating form. to show the difference: p %a|foo|.upcase |BAR|.downcase foo bar p %l|foo|.upcase |BAR|.downcase FOO bar but i don't know if these expansions of the main idea are actually possible. -- tom sawyer, aka transami transami@transami.net