good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
sharing symbolsby mungohill (Acolyte) |
on Apr 13, 2007 at 09:31 UTC ( [id://609864]=perlquestion: print w/replies, xml ) | Need Help?? |
mungohill has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks I'm sure there must be a 'derr obvious' answer to this. What I'm trying to do is to share an evolving bunch of symbolic constants between various programs. These are just integer values with names. I was thinking I'd do it in the traditional manner of an include file. So I had a 'do' file with the definitions. This was ok. Bowing to peer pressure (and because it seemed like a good idea) I thought I'd introduce 'use strict' into my program. Whereupon the compiler expressed its displeasure at references in the main program to stuff defined in the 'do' file. I thought I'd do the right thing and use a module instead, only to find that I couldn't figure out any way to export all of the symbols (for it was indeed all of them that I wanted to export) without explicitly exporting each one. This didn't appeal as I really don't like having to say things twice: it is merely an unhelpful 'opportunity to fail'. I toyed with the idea of referring in some way to the symbol table for the module but this voodoo was rather beyond me as I am ....
Thanks for all the ideas. I'm almost as gratified to see that it wasn't that obvious as I am to get the actual answer. My constants conform to /^A-Z_+$/ so I don't see having some sort of 'filtering restriction' as being too much of a problem, but I'll have to extend the list of specific exclusions. Just how many lurking hidden symbols do I need to be wary of?
Back to
Seekers of Perl Wisdom
|
|