Hi,

> Here is a basic attribute definition from an O'Reilly Book:
>
> sub new {
>
> my $invocant = shift;
> my $class = ref($invocant) || $invocant;
> my $self = {
>                    color => "bay",
>                    legs => 4,
>                    @_ ,
>         };
> return bless $self,$class;
>
> }

> What I do not understand is why $self is not defined as a hash %self.

if it makes you happy, define it as %self = ( )
the point is, you have to bless (and even more, RETURN) a reference, so
sooner or later, you'll have to say
\%self anyway... might as well start with declaring as a reference....

> Also,
> if you were to only include @_, would you need a comma after it -- in
other
> words
> my $self = {@_}; or {@_,};

doesn't matter... the , allows for appending more entries... after the last
entry you dont *need* it anymore, but it does no harm


hth,

Jos Boumans

Reply via email to