Configuring Notepad++ "Function List" for Perl
I tried your XML in Notepad++ 6.8.1 and while it does work for Perl with 'packages', my plain scripts without packages fail to produce subs now. I uncommented the lines you commented out and it fixes that problem, but does exhibit the behavior you mentioned - doubled up subs within the 'packages'.
I found the following works nicely and even ignores subs in POD (which may be there as example usage) so they aren't added to the list:
<parser id="perl_function" displayName="Perl" commentExpr="(#.*?$|(__END__.*\Z))">
<classRange mainExpr="(?<=^package).*?(?=\npackage|\Z)">
<className>
<nameExpr expr="\s\K[^;]+"/>
</className>
<function mainExpr="^[\s]*(?<!#)[\s]*sub[\s]+[\w]+[\s]*\(?[^\)\(]*?\)?[\n\s]*\{">
<functionName>
<funcNameExpr expr="(sub[\s]+)?\K[\w]+"/>
</functionName>
</function>
</classRange>
<function mainExpr="^[\s]*(?<!#)[\s]*sub[\s]+[\w]+[\s]*\(?[^\)\(]*?\)?[\n\s]*\{">
<functionName>
<nameExpr expr="(?:sub[\s]+)?\K[\w]+"/>
</functionName>
</function>
</parser>
Most probably, you should use funcNameExpr
instead of nameExpr
:
Example:
<functionName>
<funcNameExpr expr="(sub[\s]+)?\K[\w]+"/>
</functionName>