in reply to Re^2: Question about __PACKAGE__
in thread Question about __PACKAGE__

My understaning is that Foo->hello & hello are basically the same except the former is calling class method and passing 'Foo' to hello as the first arg, but the later is calling a subroutine and will not pass 'Foo'. How do you think?

I think you understand, but your wording leaves to be desired. The same sub is called in both cases; the difference is in how it's called:

Foo->hello & hello are basically the same except the former is calling hello as a class method and passing 'Foo' (or whatever's left of the arrow) as the first arg, but the latter is calling hello as a subroutine and will not pass 'Foo'.

One difference that wasn't mentioned is that inheritance will come into play when hello is called as a method.

{ package Foo; sub hello { ... } } { package Bar; our @ISA = 'Foo'; } Foo->hello('world'); # Foo::hello('Foo', 'world') Bar->hello('world'); # Foo::hello('Bar', 'world') Foo::hello('world'); # Foo::hello('world') Bar::hello('world'); # hello not found in Bar

I think the purpose of these class method calls is to initialize some class variables

And maybe even create subs, yes.