in reply to Objects and references

Your suggested form my $class = shift; is used when you know the method will only be called through the class name. The other form lets you call the method through the class name or through an existing object.

The ref method returns the class name. It will return undef if it's argument is not a ref, in which case the || will give the class name.

In the discussion mentioned above, people debate whether this is good form or not. I tend to say you should not make methods with multiple calling conventions, but Perl is about freedom and many wise programmers disagree with me.

Phil