Date: Tue, 18 Apr 2000 03:36:44 +0100 From: Paul Richards <paul@originative.co.uk> To: Steve Price <sprice@hiwaay.net> Cc: freebsd-chat@freebsd.org Subject: Re: Un*x scripting magic Message-ID: <38FBCA3C.46380367@originative.co.uk> References: <Pine.OSF.4.21.0004171843020.30502-100000@fly.HiWAAY.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Steve Price wrote:
>
> Hi all,
>
> A have a chunk of perl code something like this.
>
> # insert bunch of code here
>
> my $msg <<EndOfMessage;
> %%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 (<MESSAGE>) {
$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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38FBCA3C.46380367>
