perlquestion
halfcountplus
How can I inherit a method, in this example, test():
<code>
#!/usr/bin/perl -w
use strict;
{ package One;
sub test {
my $x = pop;
print "$x\n";
}
}
{ package Two;
use base "One";
sub new {
my $self = {};
bless($self);
}
sub eg {
test(pop);
}
}
my $obj = new Two();
$obj->eg("hello");
</code>
I know "One->test()" will work, it just seems strange to me that I could then use $obj->test(), but not test() in Two's definition.