Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Difference between executing and "using" a .pm file

by Marshall (Canon)
on Mar 30, 2021 at 19:15 UTC ( [id://11130605]=note: print w/replies, xml ) Need Help??


in reply to Re: Difference between executing and "using" a .pm file
in thread Difference between executing and "using" a .pm file

Thank you!

caller says "Returns the context of the current pure perl subroutine call. In scalar context, returns the caller's package name if there is a caller"

  • Comment on Re^2: Difference between executing and "using" a .pm file

Replies are listed 'Best First'.
Re^3: Difference between executing and "using" a .pm file
by LanX (Saint) on Mar 30, 2021 at 19:50 UTC
    The concept - like already mentioned by pryrt - is called "modulino" and was popularized by Brian D Foy IIRC.

    I'm using it regularly to run various tests when developing a module.

    Like this I can always hit F5 in my editor, no matter in which file of a project I am.

    And the current test-procedure is on top of my module in an

    unless (caller()) { BLOCK }

    Like this I don't need to always change a different make file to test the function I'm currently changing.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Thanks! I shall keep that in mind. The purpose of this validate() program is not to test my module. It is to help the user develop a consistent and accurate configuration file. Over the last 5 years of development, the syntax of this config file has become more complex. It winds up being possible to configure things that my SW doesn't consider an error, but nevertheless will could surprise the user. This is to make sure "that you've told the program to do what you want". So it spews out all sorts of explanations intended for a human to read. Updating this config file is serious business and is only typically done once per year.
        > It is to help the user develop a consistent and accurate configuration file.

        Hmm ... I'm not sure I'd use a Modulino for this.

        Something like

        perl -mMODULE=foo

        will use Module and call Module->import("foo") and you are free to let the importer do whatever you want, and you can have a variety of functions you can call.

        see perlrun -[mM][-]module=arg... for details.

        Of course calling a Modulino perl path/MODULE.pm foo can also validate the command-line options like foo here, but in this case your client needs to know the path to the installation.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11130605]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found