Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Need your advice on how to start a program

by songahji (Friar)
on May 05, 2005 at 15:54 UTC ( [id://454406]=perlquestion: print w/replies, xml ) Need Help??

songahji has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,

There are many perl style programming out there. And since my next project going to be big and maintained by lots of diff guys. I would like your input on the styling which as less obfu as possible.

Following is what I have in mind:
As usual standard module.

use strict; use warnings; use English; # This one ...? not sure
Also I use prefix $g_ on globals.
use vars qw { $g_var1 }
And POD at the end of file
__END__ =head1 NAME ... =head1 SYNOPSIS .... =head1 DESCRIPTION .... =head1 SEE ALSO .... =head1 COPYRIGHT Copyright 2005 ... ...... =cut
I am open to all suggestions.

Thanks,
Hanny J

Replies are listed 'Best First'.
Re: Need your advice on how to start a program
by polettix (Vicar) on May 05, 2005 at 16:05 UTC
    I like localising documentation, in particular I like to write documentation for a function immediately before the function itself. It helps when you have to figure out what it does, and when you make modifications you should also remember to update docs more easily.

    Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

    Don't fool yourself.

      I agree with this in theory, however in practice, interleaving code and pod comments messes up colorization in my favorite editor (emacs). I assume that it does in other editors as well. Do you have a work around or know of editors that don't exhibit this problem?

      Soon to be unemployed!

        vim has no trouble with highlighting pod blocks. The (few) other editors I've tried didn't have a problem with it, komodo, anjuta, jedit, dzsoft, and a couple others.

        --
        naChoZ

        Where in the nursery rhyme does it say Humpty Dumpty is an egg?

        Sorry to come back to this post only now, I thought I already answered this morning! I even added the emacs and cperl version as an update... on another post :)

        The only problem I have with pod colorising in cperl is that it's quite slow to be triggered, but it works well for me. I'm running emacs 21.2.2 (Slackware 9 default) with the standard provided cperl.

        Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

        Don't fool yourself.
        What version of emacs are you using? Colorizing POD works fine for me with emacs-21 on solaris and freebsd.
Re: Need your advice on how to start a program
by adrianh (Chancellor) on May 05, 2005 at 16:24 UTC
    Also I use prefix $g_ on globals.

    I'd say that the more normal Perl convention would be to use the case of the variable name to indicate scope ($local, $Global, $CONSTANT).

    And POD at the end of file...

    You might be interested in the recommended templates from Damian's forthcoming "Perl Best Practices".

      I like that $Global, $local and $CONSTANT variable name conventions. Where can I find the guidelines for normal Perl convention?

      Thanks.

        See perldoc perlstyle
Re: Need your advice on how to start a program
by tlm (Prior) on May 05, 2005 at 16:01 UTC

    I don't see anything objectionable in what you propose. I did use English for a while, but I stopped when I realized that I found the code with the old cryptic globals more readable; a case of déformation professionelle, I suppose.

    the lowliest monk

Re: Need your advice on how to start a program
by ambrus (Abbot) on May 05, 2005 at 20:30 UTC

    Just a minor suggestion. It's better to import English like this:

    use English "-no_match_vars";
    see perldoc English on what that means.
Re: Need your advice on how to start a program
by naChoZ (Curate) on May 05, 2005 at 23:32 UTC
Re: Need your advice on how to start a program
by songahji (Friar) on May 09, 2005 at 15:28 UTC
    Thanks all of you. I have made the suggested changes.

    Cheers,
    Hanny J

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://454406]
Approved by tlm
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-23 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found