Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: perl question
- To: <tlug@example.com>
- Subject: Re: perl question
- From: "Brett Robson" <brettr@example.com>
- Date: Wed, 25 Jul 2001 19:22:49 +0900
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain;charset="iso-2022-jp"
- Delivered-To: tlug@example.com
- List-Help: <mailto:tlug-request@example.comsubject=help>
- List-Post: <mailto:tlug@example.com>
- List-Subscribe: <mailto:tlug-request@example.comsubject=subscribe>
- List-Unsubscribe: <mailto:tlug-request@example.comsubject=unsubscribe>
- Old-Return-Path: <brettr@example.com>
- References: <E15PLIo-0008Av-00@example.com>
- Reply-To: tlug@example.com
- Resent-From: tlug@example.com
- Resent-Message-ID: <rDTvF.A.YGH.q2pX7@example.com>
- Resent-Sender: tlug-request@example.com
got it, thanx. ----- Original Message ----- From: <shimpei@example.com> To: <tlug@example.com> Sent: Wednesday, July 25, 2001 6:49 PM Subject: Re: perl question > > I've got this Perl code > > > > print qq~ > > <$dtd> > > <html> > > > > <head> > > blah blah > > </html> > > ~; > > > > > > Now I understand what this does, it just spits out (in this case) html tags > > to stdout. What I don't understand is why. > > "qq" is an operator that says "the next character, whatever it may be, is to be > treated as a double-quote". So everything between ~ immediately after the > qq and the next occurance of ~ is treated as a double-quoted string. > Read perlop(1) and skip to the "Quote and Quote-like Operators" section > for detail. It's useful when you have to embed double-quotes and other meta- > characters into your string. For example: > > print qq/And God said, "Let there be light!"/; > > is completely equivalent to: > > print "And God said, \"Let there be light!\""; > > but the former is more readable once you understand what the qq operator does. > In case you're wondering, there is no reason why the writer of that code > couldn't have just used double-quotes instead of qq~~, since the text > being quoted doesn't have any double-quotes. It's grammatically correct, but > needlessly obscure. > > > The Camel book gives example of here documents using this format > > print <<EOF > > blah blah > > EOF; > > They both work. The qq operator has the benefit of not screwing up your > indentation, while the << syntax frees you from having to look for that > one special character that isn't used in the text you're quoting. Remember, > the Perl mantra is: There Is More Than One Way To Do It. (I can almost hear > the python lovers in the audience snickering over that remark...) > > > Is this qq thing something new??? > > Well, it's been there since at least 1996.... > > > ----------------------------------------------------------------------- > Next Nomikai Meeting: Fri, Aug 10 19:30- Tengu Tokyo Eki-Mae > Next Technical Meeting: Sat, Sep 15 13:30- Akasaka Kumin Center > ----------------------------------------------------------------------- > more info: http://www.tlug.gr.jp Sponsor: Global Online Japan > >
- References:
- Re: perl question
- From: shimpei@example.com
Home | Main Index | Thread Index
- Prev by Date: Re: sed/vi how to concatenate all non-empty lines?
- Next by Date: Re: perl question
- Prev by thread: Re: perl question
- Next by thread: Re: perl question
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links