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??
The parens/ampersand are not much of a real problem. The unintended globals are! If you declare a lexical in the body of your script, and you have the subs declared after that, those subs can access the lexical, thus having global-like behaviour (in a way). A very, very good programming concept is to keep things to yourself if you're a piece of code.

Normal writing does not have the details at the beginning, that's true. But they don't have the conclusion and flow at the beginning! The introduction in writing can be compared to loading modules, using strict. Then, explanation comes, so you can understand the rest of the text. When that's done, body and conclusion follow.

Subs, in my opinion, are not footnotes, they form information _required_ to understand the rest of the code. That's another good reason for putting small subs that just encode data, and don't have to do much with program flow in separate modules (footnotes...).

A Perl program is executed in order. Unless you want it otherwise, it will end after having evaluated the last statement, which should be logically the end of the file. And it's a reason to put your subs at the top too! For the same reason you put use statements at the beginning: they are required pieces of knowledge to be able to fully comprehend the rest of the code.

44696420796F7520732F2F2F65206F
7220756E7061636B3F202F6D736720
6D6521203A29202D2D204A75657264


In reply to Re: Re: Re: where do you put your subs by Juerd
in thread where do you put your subs by greenFox

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 lurking in the Monastery: (4)
As of 2024-03-28 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found