NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Exporting Objects (Score:2)
The reason for not discussing that is that generally, you shouldn't mix exported functions and methods. That's because a method really expects to be called with an object as its first argument, which is less likely to happen correctly if you say method($obj) instead of $obj->method(). Also, you don't get inheritance because you're not going through method dispatch.
I'm sure there are a few cases where you might want to export things, but generally, I'd think twice before pulling in Exporter.
-Dom
Reply to This
Re:Exporting Objects (Score:2)
Wha?? (Score:2)
Some objects are written such that when you use them, you have to import the methods you'll be using, like:
use My::Module qw/ method1 method2
And others are written so you can just say:
use My::Module;
And then you automatically have access to the methods.
Jason
Re:Wha?? (Score:2)
I think you're getting confused between ordinary functions and OO code (methods). If you don't call it with an arrow, it's not a method, it's a function (with the annoying exception of the indirect method call syntax, but don't worry about that yet).
When you use a module, you're actually using OO behind the scenes, even though the results aren't usually OO. What happens is that Perl ends up calling the import() method of the named class and passing it the list that you have supplied.
What makes it a me
Re:Wha?? (Score:2)
If I could, I would mod this up.