From owner-freebsd-chat Mon Apr 17 19:36:49 2000 Delivered-To: freebsd-chat@freebsd.org Received: from mailgate.originative.co.uk (mailgate.originative.co.uk [194.217.50.228]) by hub.freebsd.org (Postfix) with ESMTP id 427A537B9AB for ; Mon, 17 Apr 2000 19:36:46 -0700 (PDT) (envelope-from paul@originative.co.uk) Received: from originative.co.uk (lobster.originative.co.uk [194.217.50.241]) by mailgate.originative.co.uk (Postfix) with ESMTP id C02C51D15F; Tue, 18 Apr 2000 03:36:44 +0100 (BST) Message-ID: <38FBCA3C.46380367@originative.co.uk> Date: Tue, 18 Apr 2000 03:36:44 +0100 From: Paul Richards Organization: Originative Solutions Ltd X-Mailer: Mozilla 4.72 [en] (X11; I; Linux 2.2.12 i386) X-Accept-Language: en-GB, en MIME-Version: 1.0 To: Steve Price Cc: freebsd-chat@freebsd.org Subject: Re: Un*x scripting magic References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Steve Price wrote: > > Hi all, > > A have a chunk of perl code something like this. > > # insert bunch of code here > > my $msg < %%MESSAGE%% > EndOfMessage > > # more code goes here > > Then I have a multi-line (printable characters only) ASCII > text file containing the message that I'd like to replace > for %%MESSAGE%%. [1] Anyone have a neat little trick in > their bag-o-magic? I know the answer should be really > obvious but everything I've tried thus either hasn't worked > or was too convoluted. What's wrong with the obvious? open(MESSAGE, $MESSAGE) || die; while () { $msg .= $_; } You can probably optimise that a bit, read the whole file in one go for starters. Paul. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message