Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Re: Modern Perl: The Book: The Draft by jethro
in thread Modern Perl: The Book: The Draft by chromatic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 03:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found