views:

131

answers:

1

The docs (Exporter and perlmodlib) say:

As a general rule, if the module is trying to be object oriented then export nothing.

But then perlmodlib also says:

Standard, bundled modules are all expected to behave in a well-defined manner with respect to namespace pollution because they use the Exporter module.

So I wonder, if you go OO and export nothing, do you really need Exporter? If you don't, does that mean that none of the standard modules are strictly OO in this sense, or does it mean they EXPORT_OK some things because you need to do that if someone wants to inherit from your module? (Is that true?) Or do you need Exporter just to be able to "use MyModule; ... = new MyModule"?

+7  A: 

You are correct. If everything will be called OBJECT::sub() or $obj->sub(), you should be fine.

For inheritance, you're going to want to use @ISA, and for that, you shouldn't need exporter.

Also, the second quote you gave is in regards to exported data pouring into a module.

If you use: use libname (); against a lib that exports using the Exporter, you are guaranteed to export nothing. That's how it can be used to prevent namespace pollution. If you explicitly export by function name, those are the only functions you get.

I had just found Pod::Template, which answered my question, but I was puzzled by @ISA being in there, yet not used. So that clarifies it--many thanks!
Kev