Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Modern Perl: The Book: The Draft

by jethro (Monsignor)
on Jul 06, 2010 at 13:06 UTC ( #848215=note: print w/replies, xml ) Need Help??

in reply to Modern Perl: The Book: The Draft

I've got two problems with Chapter 3. Paragraph "Strings":

You may escape control and non-printable characters in the string:

my $newline = "\n"; my $tab = "\t"; my $carriage = "\r";

You may also embed these control characters themselves directly into the string--a string declaration may cross lines and run as long as you want, but it's often more maintainable to use the escapes."

* 1) First sentence doesn't fit with the examples and is half wrong. You can escape '"', but you can't escape a non-printable character like the newline. You can only embed it by escaping the character 'n'. (Am I nitpicking? Could be)

I would change that to "You may embed control and non-printable characters in the string by escaping" (which is essentially the same info as in the second sentence, after the examples) or upgrade the examples to include actual characters you need to escape

* 2) The second part of the second sentence I had to read 4 times before I understood it. Since only $newline has anything to do with making a string cross lines at minimum the plural form of "escape" is misleading

Also a source of my confusion was probably the different meaning of 'crossing lines' in the source code and in the string. It should be mentioned explicitly or shown by example that if a string declaration crosses lines so does the string itself. Actually an example like

$n= "two lines";

is equivalent to

$n= "two\nlines";

might say more than a thousand words.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://848215]
and the rats come out to play...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2018-06-24 19:15 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.