develooper Front page | perl.beginners | Postings from January 2002

Re: it is bad?

Jonathan E. Paton
January 31, 2002 08:52
Re: it is bad?
Message ID:
| sub add_module
| {
|  my($tempposition,$name,@variables) = @_;
|  my $mdl_output;
|  do "$name.mdl";
|  if ($mdl_output=&ModulAdd(@variables))
|  {
|  }
|  undef &ModulAdd;
|  my $length=length($mdl_output);
| }

Indentation should be improved, although I'll only
demonstrate my preferences for 2/4 spaces per indent plus
some other preferences.

Copious commenting is useful, especially since I cannot
tell what you are trying to achieve just from this little
snippet.  At a bare minimum, you should be able to
understand each module you create SEPERATE from any others.
 If you (or a workmate) cannot, you need to comment more.

sub add_module {
    my ($tempposition, $name, @variables) = @_;

    # Comment here please
    my $mdl_output = ModulAdd(@variables);

    # Comment here please
    if ($mdl_output) {
        $html_write{$tempposition} =

    # What if we fail to get that?  Should we be doing
    else {
        # If blank, leave out the else {}

    # This is quite unusual... and need commented or
    undef &ModulAdd;

    # Wasted
    my $length=length($mdl_output);

Jonathan Paton

Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About