I'm looking for the 'right' way to call a function from within the module when that module is usually blessed. I've been putting an empty string as the first parameter passed to the function but I feel sure there is a nicer way to do this.
package Some::Module; use strict; sub new { return bless {}; } sub do_something { my ($self, $param) = @_; # ...do something... return $param; } sub do_more { my $self = shift; return do_something('example'); }
If we create an instance of this then call the function
a reference to $instance is passed to $self in the function (I think) and 'testing' is passed to $param.my $instance = Some::Module->new; $instance->do_something('testing');
But when the same function is called from within the module by do_more();, there isn't a reference to anything to be passed to do_something as the first argument so the argument list is out. Do we just add a dummy argument to the call within do_more like this
or is there a more elegant solution?sub do_more { my $self = shift; return do_something('', 'example'); }
In reply to Calling module function from within a blessed module by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |