This looks like you want do_soemthing() to act both as a method and a function.
If so, you need to check the first argument passed in. Inside that sub you would decide what to do either way.
sub do_something { my ($self, $param); $self = shift if ref $_[0] eq __PACKAGE__; # first argument is obj +ect $param = shift; # ...do something... if ($self) { # method ... } else { # function ... } return $param; }
If it is a mere function internal to the class, it is good practice to prepend the function name with a dash. That's an informal convention to mark functions private to the module or class.
If it is strictly a method, then the answers of my fellow monks apply: $self->method(@args)
In reply to Re: Calling module function from within a blessed module
by shmem
in thread Calling module function from within a blessed module
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |