in reply to Re: To be, or not to be, a package? That is the question
in thread To be, or not to be, a package? That is the question

As I haven't got my copy of PBP in front of me, pls advise as to the preferred way.

TIA ,

A user level that continues to overstate my experience :-))
  • Comment on Re^2: To be, or not to be, a package? That is the question

Replies are listed 'Best First'.
Re^3: To be, or not to be, a package? That is the question
by FunkyMonk (Bishop) on Dec 04, 2008 at 14:41 UTC
    I don't know what PBP has to say on the matter, as its one of the few Perl books I haven't bought. But...

    sub new { my $self = shift; bless \( my $scalar ), ref $self || $self; }
    Is better written as

    sub new { my $class = shift; bless \( my $scalar ), $class; }
    You don't normally get a blessed reference passed into new(). If you're using my $foo = Object::Foo->new, or something similar, its the name of the class (Object::Foo in my example) that's passed into new(). So, my $class = shift; is more logical.