Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I work with MS Source-Safe (some may say thats unfortunate ;-) whose source contol keyword expansion often doesnt play nicely with perl unless you jump through hoops (as the keywords start with a dollar sign, ie $Log gets translated, wich aint cool if youve used it as a vairable name /grr). This means that I need to put certain source control related stuff as close to the top as possible.

Other than that my preferences are fairly similar to tye and adrianh, probably the most notable difference is that I put pragmas like strict and warnings after my modules, I do this because as they are lexically scoped they have no effect on the contents of the used modules, and to me doing it this way makes this more clear, especially to a potentially inexperienced maintenance coder.

I also usually add a special block at the end for doing module test/development so that you can say perl Module.pm and have it self test or diagnostics or just plain old dev code.

package Foo::Bar; #always goes at the top! ###################################################################### +########## # $Header:: /prject/name.pl 4 02/12/04 18:46 Author + $# ($VERSION) = sprintf "%d.%03d", 1, ' $Revision:: 4 $' =~ /::\ +s+(\S+)/;# # $NoKeywords:: + $# ###################################################################### +########## use base qw/Some::Module/; # 'cause the relationship is important use Essential::CPAN::Modules; use Essential::NONCPAN::Modules; use Non::Essential::Modules; (ie debugging and the like) # I always use strict; use warnings; use warnings::register; # and maybe some other pragmas too use constant here=>1; use vars qw($Here $Should $We $Use $Them); BEGIN { # Any module specific initialization type stuff that must happen firs +t. # if vars qw() have been used and they need defaults they get them he +re. $Here||="A default value"; } sub routines_get_defined_here { } unless (caller) { # module test/development code goes here. This is useful becuase you + can then # say perl module.pm # and have it self test or devtest itself. } 1; package Virtual::Utility::Namespaces::Go::Here; 1; __END__ =pod And Pod goes here =cut


---
demerphq

<Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

• Update:  
Im a huge fan of warnings::register. I use it alot and try to avoid "normal" warnings, replacing them with warnings::warnif.



In reply to Re: Location of 'use' statements by demerphq
in thread Location of 'use' statements by djantzen

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (6)
    As of 2014-09-21 19:44 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (175 votes), past polls