in reply to Re^2: How can I avoid creating two instances of the same object
in thread How can I avoid creating two instances of the same object
The example I gave you showed you how you would call a method as a class method. The equivalent object-style call was in the comments. Speedwise, I think it's a slight benefit to call things as class methods, because Perl doesn't have to search the inheritance tree.
Using your original example, your code might looks like this:
use Data::Dumper; use User; my $dbh = User->new(); use Company; # Pretend that $dbh is a Company and call its do_something method, # equivalent to $dbh->do_something, if $dbh were a Company $dbh->Company::do_something;
|
|---|