Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Modern Perl: The Book: The Draft

by jethro (Monsignor)
on Jul 06, 2010 at 13:06 UTC ( [id://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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://848215]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-24 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found