The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
Re: My First Impressions (with errata)
[Originally posted by bbazzarrakk]

> However, it's worth pointing out that Perl internally knows that the string is
> fixed and as the code is parsed the double quotes are converted to single
> quotes.

Holy cow, I learn new things all the time! I stand corrected. Thanks for the
lesson.

James
import-bot (20211) [Avatar] Offline
#2
[Originally posted by bbazzarrakk]

First, a minor nitpick. In the benchmarking code example on page 52 the first
argument to
sprintf() only needs single quotes as nothing is interpolated. This is pretty
minor and happens all
the time, but when benchmarking it's important to do only the work you intend,
so Perl is timing
the right things for you.

Now I feel completely terrible about starting this message off on a bad note,
because this is truly a
wonderful book! I just finished Part I and I can't believe how much I have
already learned about the
things I use Perl for everyday.

Common practices are explained so clearly, you both understand them instantly
and know using
them is Doing the Right Thing. It could really be called The Art of Parsing.

My other favorite thing in this book is the code examples loaded with great
Perlisms. Things like:

@fields{@names} = split;

and

while (condition) {
do { something; last; } if condition;
}

make me embarrassed to look at my own parsers now. I've actually gone and
tried one-liners to
see what a construct was doing because I wanted to use things that looked that
cool!

Full marks from me on this one. I'm not even through it yet and I've already
recommended it to
someone.

James
import-bot (20211) [Avatar] Offline
#3
Re: My First Impressions (with errata)
[Originally posted by dave]

James,

Thanks very much for the comments. It's always nice to know that the book is
appreciated.

On the subject of the quotes. Like you, I'm the kind of person who likes to
use single quotes around fixed strings and therefore I would almost certainly
use single quotes in the example you mention.

However, it's worth pointing out that Perl internally knows that the string is
fixed and as the code is parsed the double quotes are converted to single
quotes. It's always worth using B:smilieeparse to check things like this:

$ perl -MO=Deparse -le 'print "foo"'

print 'foo';

-e syntax OK

$ perl -MO=Deparse -le 'print "$foo"'

print "$foo";

-e syntax OK

Notice that in the first example (with a fixed string) the double quotes are
converted to single quotes, but in the second example (with a variable) the
double quotes are retained.

Hope that helps,

Dave...