Joe wrote:
Is there a simple way to add a method to an object? Basically, what I
want to do is this:
$window->CenterOnScreen();
#Minimalistic example
use Data::Dumper;
sub Win32::GUI::Window::CenterOnScreen { my $self = shift;
print "In CenterOnScreen\n";
print Dumper($self);
}
Or if you have a number of subs to add, enter package Win32::GUI::Window
like this:
package Win32::GUI::Window;
use Data::Dumper;
sub CenterOnScreen { my $self = shift;
print "In CenterOnScreen\n";
print Dumper($self);
}
I don't know which is more obvious to the reader. I guess the second
approach where you explicitly change package.
/J
------ ---- --- -- -- -- - - - - -
Johan Lindström Boss Casinos
Sourcerer [EMAIL PROTECTED]
http://www.bahnhof.se/~johanl/
If the only tool you have is a hammer,
everything tends to look
like a nail