Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: Correct syntax for using $INC to keep modules in same file

by chromatic (Archbishop)
on Oct 14, 2012 at 04:13 UTC ( #998913=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Correct syntax for using $INC to keep modules in same file
in thread can't import using exporter

Something like this:

package mem; sub import { my (undef, $package) = @_; $package =~ s!::!/!g; $INC{$package . '.pm'} = 1; }

As long as that appears logically before any use mem 'foo'; statements in your program, everything should work correctly. It's slightly more typing than your implementation of mem, but it keeps all of the details of the implementation in one place.


Comment on Re^5: Correct syntax for using $INC to keep modules in same file
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-09-30 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (363 votes), past polls