Subject: | Example get_code_info() doesn't work for explicitly unnamed subs |
$ perl -MData::Dumper -MSub::Util=set_subname -MSub::Identify=get_code_info -e 'print Dumper [ get_code_info(set_subname "", sub {}) ]'
$VAR1 = [
'main',
''
];
$ perl -MData::Dumper -MSub::Util=subname,set_subname -e 'sub get_code_info { return (subname $_[0]) =~ m/^(.+)::(.+?)$/ }; print Dumper [ get_code_info(set_subname "", sub {}) ]'
$VAR1 = [];
With a slight tweak, this returns the same as Sub::Identify's get_code_info:
$ perl -MData::Dumper -MSub::Util=subname,set_subname -e 'sub get_code_info { return (subname $_[0]) =~ m/^(.+)::(.*?)$/ }; print Dumper [ get_code_info(set_subname "", sub {}) ]'
$VAR1 = [
'main',
''
];
That is, replace the final (.+?) with (.*?).