http://mail.pm.org/pipermail/belfast-pm/2004-February/002482.html might be interesting.
On 2013-03-05, at 4:22 PM, Uri Guttman <[email protected]> wrote: > On 03/05/2013 12:24 PM, Greg London wrote: >> >>> the one thing that >>> seems a bit odd is that Greg's example didn't have separate packages for >>> the separate files >> >> yeah, I did something like this a long time ago, and can't >> remember how I did it exactly. >> >> Basically, I pulled the file in like a #include >> so no enclosing package because I wanted the constants >> to be #included directly into the package that was doing >> the #include. >> >> It's vaguely coming back to me that "use" just reads the >> file once, and after the first "use" perl just calls >> the import function. So, whatever I did way back when, >> I didn't use the "use" directive. >> >> I might have slurped the file and evaled it or something. >> Probably going to programmer hell for that. >> >> Anyway, I can't remember what I did, so I put a package around >> it and use the Exporter module to export the constants. >> >> Is there a way to tell Exporter to export all the subs >> in the package? I'm not very familiar with Exporter, >> but reading the docs, it is kind of funny that its an >> export module that discourages people from exporting. >> >> If exporting is really, really bad, then the module shouldn't >> exist at all. If the module exists, then let me export >> everything if I really want to. >> >> A file full of constants is only useful if they're exported. > > well, you could write your own import method. actual exporting is trivial - > it is just assigning a ref to the typeglob in the importing namespace. you > can easily scan your own (the constants module) namespace and find all the > subs with upper case names. then just get refs to them (or their glob entries > for code refs, otherwise you need symrefs). then use caller() to find the > namespace of the importing module and assign all the code refs into that > space. > > sounds like a module to do this (Constant::Export) might be useful. > > uri > > > > _______________________________________________ > Boston-pm mailing list > [email protected] > http://mail.pm.org/mailman/listinfo/boston-pm -- Mike Stok <[email protected]> http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

