How does Perl module(.pm) call corresponding .so?
I just compiled and run a hello world Perl extension,but I don't know the principle.How does the .pm
call .开发者_开发问答so
?
It doesn't need to - the binary code defines some variables and functions in the module's namespace, they can be used just like regular variables. The .pm
file only needs to ensure that .so
is loaded when it is needed. This is done by the DynaLoader module. By inheriting from DynaLoader
you make sure that your .so
file is loaded when an unknown method is called on your class.
精彩评论