Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 04 Feb 2002 12:25:30 -0330
From:      Paul David Fardy <pdf@morgan.ucs.mun.ca>
To:        cjclark@alum.mit.edu
Cc:        questions@FreeBSD.org
Subject:   Re: Perl question... 
Message-ID:  <200202041555.g14FtVSU004141@plato.ucs.mun.ca>
In-Reply-To: Your message of "Fri, 01 Feb 2002 15:22:07 PST." <20020201152207.C956@gohan.cjclark.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Feb 01, 2002 at 05:24:46PM -0330, Paul David Fardy wrote:
>> I've been using Perl so much, I've forgotten some of my shell rules.
>> I tested this code because I thought "$TTL" would result in the
>> expansion of an undefined variable TTL.  In Perl, it _would_ be a
>> problem.  In sh, it's fine.

Your message dated: Fri, 01 Feb 2002 15:22:07 PST
>  It is not expanded because I quoted "EOF" as the here-doc
>  delimiter. If I had not, it would have been.
>> 		ed $file <<"EOF"

Yeah, I realize that (now).  I was just noting the re-wiring of my
brain to follow Perl's rules wherein the expansion of a here-doc is 
enabled by

	<<"EOF"

and disabled by

	<<'EOF'

This should probably have been just my "note-to-self".  But I figure
it has enough educational value under the subject ("Perl question")
that others might learn from it.

 1) Perl and the shells have a useful feature called "here documents";
 2) one needs to be careful about the expansion of variables within a
    here-doc (irrespective of which language you use); and
 3) the Perl and shell rules for here docs differ in significant ways.

Paul

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202041555.g14FtVSU004141>