Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: here documents Message-ID: <1990Jul31.013220.3903@iwarp.intel.com> Date: 31 Jul 90 01:32:20 GMT References: <7192@star.cs.vu.nl> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 93 In-Reply-To: maart@cs.vu.nl (Maarten Litmaath) In article <7192@star.cs.vu.nl>, maart@cs (Maarten Litmaath) writes: | How about adding a `<<-' here document operator, which strips leading | tabs and spaces off the lines forming the document? (And the line | trailing the document.) Current practice in sh. Preserves indentation | in the script. Currently the only workarounds I can think of are: | | 1) | print "Newsgroups: $Newsgroups\n" | . "Subject: $Subject\n" | . "Summary: \n" | . "Expires: \n" | . "References:$References\n" | . "Reply-To: $Name\@$Domainname ($Fullname)\n" | . "Followup-To: \n" | . "Distribution: $Distribution\n" | . "Organization: $Organization\n" | . "Keywords: \n" | . "\n" | . "In article $Message_ID,\n" | . "\t$Orig_From writes:\n"; | | [Sic!] | | 2) | sub here { | $_[0] =~ s/((^|\n))[ \t]+/$1/g; | $_[0] =~ s/((^|\n))\\/$1/g; | $_[0]; | } | print &here(<<" EOF"); | Newsgroups: $Newsgroups | Subject: $Subject | Summary: | Expires: | References:$References | Reply-To: $Name\@$Domainname ($Fullname) | Followup-To: | Distribution: $Distribution | Organization: $Organization | Keywords: | | In article $Message_ID, | \\\t$Orig_From writes: | EOF | | BTW, I'd like `<<"\tEOF"' to work as well... | | [Remember, we're talking about _readability_ here, Randal! :-) ] Well, since you invoked the name of the daemon, here's what I do: ================================================== ## next few lines are magic to get reasonable output. ## pay no attention to the man behind the curtain... for (split(/\s+/, <