给出一个Perl包Foo.pm,例如
package Foo;
use strict;
sub bar {
# some code here
}
sub baz {
# more code here
}
1;
Run Code Online (Sandbox Code Playgroud)
如何编写脚本来提取每个sub的文本源代码,从而产生一个哈希:
$VAR1 = {
'bar' => 'sub bar {
# some code here
}',
'baz' => 'sub baz {
# more code here
}'
};
Run Code Online (Sandbox Code Playgroud)
我希望文本与包,空白和所有内容完全一致.
谢谢.