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.
-
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.
|