in reply to Pure perl lexical sub import
Thenuse v5.36; package Foo::Internal { use Scalar::Util 'looks_like_number'; sub check_it ($self, $num) { say 'Hoorah!' if looks_like_number($num); } } package Foo { sub new ($class) { bless {} => $class; } no warnings 'once'; *check_it = \&Foo::Internal::check_it; } my $foo = Foo->new; $foo->check_it(42); $foo->looks_like_number(42);
% perl internal.pl Hoorah! Can't locate object method "looks_like_number" via package "Foo" at in +ternal.pl line 22.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pure perl lexical sub import
by NERDVANA (Priest) on Dec 22, 2024 at 20:01 UTC | |
by Arunbear (Prior) on Dec 23, 2024 at 12:39 UTC |