I have some module, and want to make alias for some sub. Here is the code:
#!/usr/bin/perl
package MySub;
use strict;
use warnings;
sub new {
my $class = shift;
my $params = shift;
my $self = {};
bless( $self, $class );
return $self;
}
sub do_some {
my $self = shift;
print "Do something!";
return 1;
}
*other = \&do_some;
1;
It works, but it produces a compile warning
Name "MySub::other" used only once: possible typo at /tmp/MySub.pm line 23.
I know that I can just type no warnings 'once';
, but is this the only solution? Why is Perl warning me? What am I doing wrong?
sub other {do_some(@_);}
– Clercq*other = \&do_some;
is recommended for making subroutine aliases, and i was wondered when get this warning – Hulse