/usr/share/perl5/pod
NameSizeModeActions
a2p.pod61070644editdlrm
perl.pod157480644editdlrm
perl56delta.pod1071840644editdlrm
perl58delta.pod1149080644editdlrm
perl561delta.pod1246970644editdlrm
perl570delta.pod216550644editdlrm
perl571delta.pod303820644editdlrm
perl572delta.pod255510644editdlrm
perl573delta.pod46440644editdlrm
perl581delta.pod380600644editdlrm
perl582delta.pod44700644editdlrm
perl583delta.pod63350644editdlrm
perl584delta.pod73630644editdlrm
perl585delta.pod58890644editdlrm
perl586delta.pod46510644editdlrm
perl587delta.pod83570644editdlrm
perl588delta.pod252670644editdlrm
perl589delta.pod539050644editdlrm
perl590delta.pod349510644editdlrm
perl591delta.pod111730644editdlrm
perl592delta.pod109540644editdlrm
perl593delta.pod170340644editdlrm
perl594delta.pod126610644editdlrm
perl595delta.pod189340644editdlrm
perl5004delta.pod562400644editdlrm
perl5005delta.pod342850644editdlrm
perl5100delta.pod539220644editdlrm
perl5101delta.pod438770644editdlrm
perlaix.pod181280644editdlrm
perlamiga.pod70310644editdlrm
perlapi.pod1694280644editdlrm
perlapio.pod193320644editdlrm
perlapollo.pod8290644editdlrm
perlartistic.pod68020644editdlrm
perlbeos.pod29390644editdlrm
perlbook.pod6630644editdlrm
perlboot.pod283550644editdlrm
perlbot.pod116750644editdlrm
perlbs2000.pod79290644editdlrm
perlcall.pod551730644editdlrm
perlce.pod92570644editdlrm
perlcheat.pod41530644editdlrm
perlclib.pod76840644editdlrm
perlcn.pod49150644editdlrm
perlcommunity.pod63980644editdlrm
perlcompile.pod95160644editdlrm
perlcygwin.pod281830644editdlrm
perldata.pod368790644editdlrm
perldbmfilter.pod49870644editdlrm
perldebguts.pod318870644editdlrm
perldebtut.pod213040644editdlrm
perldebug.pod375350644editdlrm
perldelta.pod438770644editdlrm
perldgux.pod28210644editdlrm
perldiag.pod1831510644editdlrm
perldoc.pod73100644editdlrm
perldos.pod108530644editdlrm
perldsc.pod254470644editdlrm
perlebcdic.pod666070644editdlrm
perlembed.pod380330644editdlrm
perlepoc.pod37790644editdlrm
perlfaq.pod248410644editdlrm
perlfaq1.pod177620644editdlrm
perlfaq2.pod216140644editdlrm
perlfaq3.pod385340644editdlrm
perlfaq4.pod814120644editdlrm
perlfaq5.pod492010644editdlrm
perlfaq6.pod385380644editdlrm
perlfaq7.pod375880644editdlrm
perlfaq8.pod461280644editdlrm
perlfaq9.pod241910644editdlrm
perlfilter.pod211400644editdlrm
perlfork.pod114400644editdlrm
perlform.pod168940644editdlrm
perlfreebsd.pod19500644editdlrm
perlfunc.pod2919090644editdlrm
perlglossary.pod1121390644editdlrm
perlgpl.pod188060644editdlrm
perlguts.pod1051820644editdlrm
perlhack.pod1215120644editdlrm
perlhaiku.pod15040644editdlrm
perlhist.pod387660644editdlrm
perlhpux.pod286500644editdlrm
perlhurd.pod19900644editdlrm
perlintern.pod264080644editdlrm
perlintro.pod214910644editdlrm
perliol.pod337550644editdlrm
perlipc.pod677610644editdlrm
perlirix.pod43970644editdlrm
perljp.pod80700644editdlrm
perlko.pod78920644editdlrm
perllexwarn.pod144350644editdlrm
perllinux.pod14920644editdlrm
perllocale.pod416160644editdlrm
perllol.pod82520644editdlrm
perlmachten.pod45000644editdlrm
perlmacos.pod21110644editdlrm
perlmacosx.pod113220644editdlrm
perlmint.pod95390644editdlrm
perlmod.pod244940644editdlrm
perlmodinstall.pod139290644editdlrm
perlmodlib.pod773330644editdlrm
perlmodstyle.pod211140644editdlrm
perlmpeix.pod150870644editdlrm
perlmroapi.pod29590644editdlrm
perlnetware.pod64880644editdlrm
perlnewmod.pod112140644editdlrm
perlnumber.pod83520644editdlrm
perlobj.pod218130644editdlrm
perlop.pod962250644editdlrm
perlopenbsd.pod12070644editdlrm
perlopentut.pod379970644editdlrm
perlos2.pod927830644editdlrm
perlos390.pod160740644editdlrm
perlos400.pod46180644editdlrm
perlothrtut.pod406570644editdlrm
perlpacktut.pod510470644editdlrm
perlperf.pod513280644editdlrm
perlplan9.pod51250644editdlrm
perlpod.pod216260644editdlrm
perlpodspec.pod677920644editdlrm
perlport.pod863020644editdlrm
perlpragma.pod43200644editdlrm
perlqnx.pod42460644editdlrm
perlre.pod827980644editdlrm
perlreapi.pod254270644editdlrm
perlrebackslash.pod201090644editdlrm
perlrecharclass.pod219090644editdlrm
perlref.pod264650644editdlrm
perlreftut.pod186700644editdlrm
perlreguts.pod368770644editdlrm
perlrepository.pod234530644editdlrm
perlrequick.pod176170644editdlrm
perlreref.pod119960644editdlrm
perlretut.pod1150050644editdlrm
perlriscos.pod15110644editdlrm
perlrun.pod499280644editdlrm
perlsec.pod235420644editdlrm
perlsolaris.pod291310644editdlrm
perlstyle.pod86180644editdlrm
perlsub.pod542220644editdlrm
perlsymbian.pod162220644editdlrm
perlsyn.pod310900644editdlrm
perlthrtut.pod465100644editdlrm
perltie.pod366650644editdlrm
perltoc.pod6429870644editdlrm
perltodo.pod483600644editdlrm
perltooc.pod514250644editdlrm
perltoot.pod686250644editdlrm
perltrap.pod411510644editdlrm
perltru64.pod77360644editdlrm
perltw.pod53840644editdlrm
perlunicode.pod561690644editdlrm
perlunifaq.pod128780644editdlrm
perluniintro.pod329730644editdlrm
perlunitut.pod79070644editdlrm
perlutil.pod98810644editdlrm
perluts.pod31800644editdlrm
perlvar.pod591330644editdlrm
perlvmesa.pod39520644editdlrm
perlvms.pod525450644editdlrm
perlvos.pod55670644editdlrm
perlwin32.pod408090644editdlrm
perlxs.pod741940644editdlrm
perlxstut.pod496700644editdlrm
Edit: /usr/share/perl5/pod/perlstyle.pod (8618B)
=head1 NAME perlstyle - Perl style guide =head1 DESCRIPTION Each programmer will, of course, have his or her own preferences in regards to formatting, but there are some general guidelines that will make your programs easier to read, understand, and maintain. The most important thing is to run your programs under the B<-w> flag at all times. You may turn it off explicitly for particular portions of code via the C pragma or the C<$^W> variable if you must. You should also always run under C or know the reason why not. The C and even C pragmas may also prove useful. Regarding aesthetics of code lay out, about the only thing Larry cares strongly about is that the closing curly bracket of a multi-line BLOCK should line up with the keyword that started the construct. Beyond that, he has other preferences that aren't so strong: =over 4 =item * 4-column indent. =item * Opening curly on same line as keyword, if possible, otherwise line up. =item * Space before the opening curly of a multi-line BLOCK. =item * One-line BLOCK may be put on one line, including curlies. =item * No space before the semicolon. =item * Semicolon omitted in "short" one-line BLOCK. =item * Space around most operators. =item * Space around a "complex" subscript (inside brackets). =item * Blank lines between chunks that do different things. =item * Uncuddled elses. =item * No space between function name and its opening parenthesis. =item * Space after each comma. =item * Long lines broken after an operator (except C and C). =item * Space after last parenthesis matching on current line. =item * Line up corresponding items vertically. =item * Omit redundant punctuation as long as clarity doesn't suffer. =back Larry has his reasons for each of these things, but he doesn't claim that everyone else's mind works the same as his does. Here are some other more substantive style issues to think about: =over 4 =item * Just because you I do something a particular way doesn't mean that you I do it that way. Perl is designed to give you several ways to do anything, so consider picking the most readable one. For instance open(FOO,$foo) || die "Can't open $foo: $!"; is better than die "Can't open $foo: $!" unless open(FOO,$foo); because the second way hides the main point of the statement in a modifier. On the other hand print "Starting analysis\n" if $verbose; is better than $verbose && print "Starting analysis\n"; because the main point isn't whether the user typed B<-v> or not. Similarly, just because an operator lets you assume default arguments doesn't mean that you have to make use of the defaults. The defaults are there for lazy systems programmers writing one-shot programs. If you want your program to be readable, consider supplying the argument. Along the same lines, just because you I omit parentheses in many places doesn't mean that you ought to: return print reverse sort num values %array; return print(reverse(sort num (values(%array)))); When in doubt, parenthesize. At the very least it will let some poor schmuck bounce on the % key in B. Even if you aren't in doubt, consider the mental welfare of the person who has to maintain the code after you, and who will probably put parentheses in the wrong place. =item * Don't go through silly contortions to exit a loop at the top or the bottom, when Perl provides the C operator so you can exit in the middle. Just "outdent" it a little to make it more visible: LINE: for (;;) { statements; last LINE if $foo; next LINE if /^#/; statements; } =item * Don't be afraid to use loop labels--they're there to enhance readability as well as to allow multilevel loop breaks. See the previous example. =item * Avoid using C (or C) or `backticks` in a void context, that is, when you just throw away their return values. Those functions all have return values, so use them. Otherwise use a C loop or the C function instead. =item * For portability, when using features that may not be implemented on every machine, test the construct in an eval to see if it fails. If you know what version or patchlevel a particular feature was implemented, you can test C<$]> (C<$PERL_VERSION> in C) to see if it will be there. The C module will also let you interrogate values determined by the B program when Perl was installed. =item * Choose mnemonic identifiers. If you can't remember what mnemonic means, you've got a problem. =item * While short identifiers like C<$gotit> are probably ok, use underscores to separate words in longer identifiers. It is generally easier to read C<$var_names_like_this> than C<$VarNamesLikeThis>, especially for non-native speakers of English. It's also a simple rule that works consistently with C. Package names are sometimes an exception to this rule. Perl informally reserves lowercase module names for "pragma" modules like C and C. Other modules should begin with a capital letter and use mixed case, but probably without underscores due to limitations in primitive file systems' representations of module names as files that must fit into a few sparse bytes. =item * You may find it helpful to use letter case to indicate the scope or nature of a variable. For example: $ALL_CAPS_HERE constants only (beware clashes with perl vars!) $Some_Caps_Here package-wide global/static $no_caps_here function scope my() or local() variables Function and method names seem to work best as all lowercase. E.g., C<$obj-Eas_string()>. You can use a leading underscore to indicate that a variable or function should not be used outside the package that defined it. =item * If you have a really hairy regular expression, use the C modifier and put in some whitespace to make it look a little less like line noise. Don't use slash as a delimiter when your regexp has slashes or backslashes. =item * Use the new C and C operators to avoid having to parenthesize list operators so much, and to reduce the incidence of punctuation operators like C<&&> and C<||>. Call your subroutines as if they were functions or list operators to avoid excessive ampersands and parentheses. =item * Use here documents instead of repeated C statements. =item * Line up corresponding things vertically, especially if it'd be too long to fit on one line anyway. $IDX = $ST_MTIME; $IDX = $ST_ATIME if $opt_u; $IDX = $ST_CTIME if $opt_c; $IDX = $ST_SIZE if $opt_s; mkdir $tmpdir, 0700 or die "can't mkdir $tmpdir: $!"; chdir($tmpdir) or die "can't chdir $tmpdir: $!"; mkdir 'tmp', 0777 or die "can't mkdir $tmpdir/tmp: $!"; =item * Always check the return codes of system calls. Good error messages should go to C, include which program caused the problem, what the failed system call and arguments were, and (VERY IMPORTANT) should contain the standard system error message for what went wrong. Here's a simple but sufficient example: opendir(D, $dir) or die "can't opendir $dir: $!"; =item * Line up your transliterations when it makes sense: tr [abc] [xyz]; =item * Think about reusability. Why waste brainpower on a one-shot when you might want to do something like it again? Consider generalizing your code. Consider writing a module or object class. Consider making your code run cleanly with C and C (or B<-w>) in effect. Consider giving away your code. Consider changing your whole world view. Consider... oh, never mind. =item * Try to document your code and use Pod formatting in a consistent way. Here are commonly expected conventions: =over 4 =item * use CE> for function, variable and module names (and more generally anything that can be considered part of code, like filehandles or specific values). Note that function names are considered more readable with parentheses after their name, that is C. =item * use CE> for commands names like B or B. =item * use CE> or CE> for file names. CE> should be the only Pod code for file names, but as most Pod formatters render it as italic, Unix and Windows paths with their slashes and backslashes may be less readable, and better rendered with CE>. =back =item * Be consistent. =item * Be nice. =back