Good job I decided to write this as two posts.
> Most of what you wrote is redundant in this
> particular case. You could have written:
(I was just refering to the constructor, btw.)
> package foo;
> sub bar { bless \$qux };
> .
> .
> package waldo;
> $emerson = foo->new;
That should of course have been:
> $emerson = foo->bar;
Or you could have been conventional, and called the sub new,
which is what the next part of my email assumed.
> The $self = {} bit
The use of $self is again just convention. You could have
written:
sub new {
my $type = shift;
bless {},$type;
}
or
sub new {
bless {},shift;
}
or, if you don't want to be able to store instance data:
sub new {
bless \$foo,shift;
}
Now for the reason I was really going to send this second
post. The mistake you made would have been pointed out
to you (albeit in greek), if you had used:
use strict;
You should get in to the habit of writing this. It would have
forced you to also use my for $a etc, but that's ok. And
while I'm about it, you should also switch on warnings by
using the -w switch:
#!/usr/bin/perl -w
You should burn these two in to your brain. Using -w and
strict will give you a couple extra problems when you first
start using them, but thereafter they will save you a lot of
headaches.