in reply to does a subroutine exist? defined vs glob

Running it under 5.10 where the subroutine doesn't exist I think suggests an explaination:

C:\test>1135926.pl $VAR1 = ''; $VAR1 = ''; Goto undefined subroutine &Config::non_bincompat_options at C:/perl64/ +lib/Config_heavy.pl line 1290.

Ie. It is autoloaded.

Which is confirmed by running it with 5.18 and -d:Trace I get:

>> [0] 1135926.pl : 7: pp( Config::non_bincompat +_options() ); >> [0] C:/perl5.18/perl/lib/Config.pm: 81: require 'Config_heavy +.pl'; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 5: use strict; ... >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 6: use warnings; ... >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 7: use vars '%Config'; ... >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 75: our $summary = <<'! +END!'; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 108: my $summary_expande +d; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 129: local *_ = \my $a; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 130: $_ = <<'!END!'; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1231: my $i = ord(8); ... >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1233: our $byteorder = jo +in('', unpack('aaaaaaaa', pack('Q', $i))); >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1234: s/(byteorder=)(['"] +).*?\2/$1$2$Config::byteorder$2/m; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1236: my $config_sh_len = + length $_; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1238: our $Config_SH_expa +nded = "\n$_" . << 'EOVIRTUAL'; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1244: eval { >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1246: require 'Confi +g_git.pl'; >> [0] C:/perl5.18/perl/lib/Config_git.pl: 5: $Config::Git_Data=<<' +ENDOFGIT'; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1247: $Config_SH_exp +anded .= $Config::Git_Data; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1248: 1; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1275: my $prevpos = 0; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1301: *DELETE = *CLEAR = +\*STORE; # Typeglob aliasing uses less space >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1342: 1; >> [0] C:/perl5.18/perl/lib/Config.pm: 82: goto \&launcher unles +s $Config::AUTOLOAD =~ /launcher$/; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1338: undef &AUTOLOAD +; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 1339: goto \&$Config: +:AUTOLOAD; >> [0] C:/perl5.18/perl/lib/Config_heavy.pl: 14: return split ' +', (Internals::V())[1];

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

Replies are listed 'Best First'.
Re^2: does a subroutine exist? defined vs glob
by Anonymous Monk on Jul 23, 2015 at 16:44 UTC
    Yes. To amplify the point about autoloading, try this:
    use Config; print "defined before\n" if defined &Config::non_bincompat_options; Config::non_bincompat_options(); print "defined after\n" if defined &Config::non_bincompat_options;
    Calling the sub causes it to become defined through autoloading.
      ... and there's a bit of magic that I hadn't realized before, because you can do the same thing with a coderef.
      use Config; my $sub = *Config::non_bincompat_options{CODE}; print "defined before\n" if defined &$sub; $sub->(); print "defined after\n" if defined &$sub;
      Same result: not defined before, but defined after.