Given a Perl package Foo.pm, e.g.
package Foo;
use strict;
sub bar {
# some code here
}
sub baz {
# more code here
}
1;
How can I write a script to extract the textual source code for each sub, resulting in a hash:
$VAR1 = {
'bar' => 'sub bar {
# some code here
}',
'baz' => 'sub baz {
# more code here
}'
};
I'd like to have the text exactly as it appears in the package, whitespace and all.
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…