Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I was browsing through the Perl Data Structures documentation and noticed that though the document suggests using strict, it's not used in any examples.

Actually, it says "WHY YOU SHOULD ALWAYS use strict".

And what alternative do you suggest? Putting it in every example would make the examples longer and the document harder to read, which is why there's a whole separate section near the start of the document explaining it. Many of the examples also run fine in the absence of strict and warnings. <update> To clarify, obviously one should still always use strict and warnings. But the documentation does still cater to those who don't. Plus, not every code snippet is intended to be a full program. If a code example were to fail in the presence of use strict; use warnings;, I'd call that a documentation issue. But again, I still don't see any concrete suggestions in this thread. </update>

perlintro, the Camel, Modern Perl, and many other resources on learning Perl explain fairly early on why one should always Use strict and warnings. use v5.12; and up, which is required for many modern features to work, also turns on strict.

How's someone who's new to Perl supposed to know when some internally provided variable is being used vs when a user created variable is being used in the code?

From context and from trying out the examples.

So just in case this isn't a troll: Feel free to submit patches for cases that you think are unclear.


In reply to Re: Why Perl Docs examples do not use strict and warnings often (updated) by haukex
in thread Why Perl Docs examples do not use strict and warnings often by Anonymous Monk

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 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? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2022-07-06 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?