Front page | perl.beginners |
Postings from January 2002
Re: it is bad?
From:
Jonathan E. Paton
Date:
January 31, 2002 08:52
Subject:
Re: it is bad?
Message ID:
20020131165202.75319.qmail@web14604.mail.yahoo.com
| sub add_module
| {
| my($tempposition,$name,@variables) = @_;
| my $mdl_output;
| do "$name.mdl";
| if ($mdl_output=&ModulAdd(@variables))
| {
|
$html_write{$tempposition}="$html_write{$tempposition}$mdl_output";
| }
| 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
$name.mdl->();
my $mdl_output = ModulAdd(@variables);
# Comment here please
if ($mdl_output) {
$html_write{$tempposition} =
"$html_write{$tempposition}$mdl_output";
}
# What if we fail to get that? Should we be doing
anything?
else {
# If blank, leave out the else {}
}
# This is quite unusual... and need commented or
explaination
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
http://uk.my.yahoo.com