Things that belong together should go together
Minimize scope. Declare variables the closest they can be to the first place they are used.
=head1 NAME
Coffee - Virtual coffee (better, faster and stronger than Java)
=head1 METHODS
=head2 new()
new() will return a Coffee object. It uses only the finest beans straight out of the sack, just in from a Brazilian coffee commune.
=cut
sub new {
my $class = shift;
my $self = bless { }, ref( $class ), $class;
$self->_getBeans();
$self->_grind();
$self->_brew();
return( $self );
}
Re:docs
chromatic on 2003-06-24T19:21:52
Could you comment this line?
my $self = bless { }, ref( $class ), $class;Re:docs
inkdroid on 2003-06-24T20:20:46
## error ## my $self = bless { }, ref( $class ), $class;
my $self = bless { }, ref( $class ) || $class;Re:docs
inkdroid on 2003-06-24T20:28:30
rather:...
## this is an error
## my $self = bless {}, ref( $class ), $class
## this allows new() to be called as an object method ( $obj->new() )
## as well as class method ( Coffee->new() )
my $self = bless{}, ref( $class ) || $class;
...