in reply to OOP method usage
As others have pointed out, the correct code for sub2 is something like this:
sub sub2 { my ($self) = @_; $self->_sub1; }
In this particular case, because sub2 isn't actually doing anything, other than passing straight through to _sub1, there are a couple of other options which perform better, CPU and memory wise:
# Use goto because that automatically passes on @_ to the # next function. sub sub2 { goto \&_sub1; }
or:
# Just make one sub into an alias for the other... *sub2 = \&_sub1;
There are considerations to make regarding things like inheritance though, so while each of these are faster, the first example is in many ways "better".
|
|---|