in reply to Re^2: Pure perl lexical sub import
in thread Pure perl lexical sub import

There'd be one package which is your actual clean namespace meant for end users, and another package containing the implementation details.

It only looks ugly because I was tired and didn't use Exporter. So with Exporter it would be like this

:::::::::::::: Foo/Internal.pm :::::::::::::: use v5.36; package Foo::Internal { use Exporter 'import'; our @EXPORT = qw[check_it]; use Scalar::Util 'looks_like_number'; sub check_it ($self, $num) { say 'Hoorah!' if looks_like_number($num); } } 1; :::::::::::::: Foo.pm :::::::::::::: use v5.36; package Foo { use Foo::Internal; sub new ($class) { bless {} => $class; } } 1; :::::::::::::: clean.pl :::::::::::::: use v5.36; use Foo; my $foo = Foo->new; $foo->check_it(42); $foo->looks_like_number(42);