linux - Perl script usable as a program and as a module -


I have a Perl script (standalone program) that contains some subs and want to reuse it in other scripts. Due to the limitations of the performance environment, I can not move the function to a typical .pm file.

Is it possible to distinguish whether the script requires a standalone program or is it ed / do written by another script?

The only thing I could get was that the caller at the top level: there is no collar in the standalone program, while when is required ed Caller shows which module was loaded. Is there a better solution?

Yes, your caller approach was correct - it's called "modulin" Technique I'm guessing that Brian invented it until someone exposed me to the contrary.

The main working part of the modulin looks like this (from the answer given below from below):

  __ PACKAGE__ - & gt; Run (@rrgv) until collar no; Sub run {my ($ square, @args) = @_; } 1; 


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -