Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

If you want to be sure certain modules are loaded from your application library, you can set @INC to include only the application library (or libraries as the case may be) rather than prepending the application library. In this way, if the module isn't in the application library it isn't loaded. For example:

#!/usr/bin/perl # use strict; use warnings; BEGIN { local @INC = ( "/opt/app/lib" ); eval "use Application::Module"; }

If the modules in your application library use modules from the standard library and assume a default @INC, then you can't change @INC when you use them but you can check %INC after they are loaded to ensure they are loaded form the correct location.

For example, if you wanted to load a patched version of File::Find from your application directory and fail if it was accidentally omitted from there you could do something like the following:

#!/usr/bin/perl # use strict; use warnings; use constant APPLIB => "/opt/app/lib"; use lib APPLIB; use File::Find; substr($INC{'File/Find.pm'},0,length(APPLIB)) eq APPLIB or die "File::Find incorrectly loaded from " . $INC{'File/Find.pm' +};

In reply to Re: Restricting @INC for specific application need by ig
in thread Restricting @INC for specific application need by naikonta

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-19 09:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found