On Mon, 21 Nov 2022 15:33:12 -0300 breno <oainikusama@gmail.com> wrote: > Dear porters, > > when sub bar is not declared at all, 'sub foo { bar() }' compiles > under strict/warnings without any issues. Same goes for 'my $x = > \&bar'. > > Is this by design? I understand why glob refs would not warn or croak > but Is there a reason why explicitly named subroutines that don't > exist at compile time would not yield even a warning until they are > actually called? Short answer: AUTOLOAD Long answer: Back when memory and CPU were nowhere near as large/fast as they are now, it was common for a perl module to not try to define dozens or hundreds of subs on startup, because that would slow things down and eat memory. Instead it would keep them in plain text somewhere cheap, and provide an AUTOLOAD sub that would lazily define & compile them as necessary, first time they were called. -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/Thread Previous