Re: Is it a pragma or a module?
by ikegami (Patriarch) on Dec 14, 2006 at 17:04 UTC
|
You can't. Sometimes, you can't even tell by reading the docs! There's a couple of signs, however.
- Does the module use %^H or $^H? If so, almost definitely.
- Does the module use %^H or $^H? If not, it could still be.
- Does the module (or a parent) have an unimport method? If so, it's almost certainly a pragma.
- Does the module (or a parent) have an unimport method? If not, it's definitely not a pragma.
- Is the module name lowercase? If so, it has a higher chance of being a pragma.
- Is the module name lowercase? If not, it has a lower chance of being a pragma.
- Is the module a core module with a lowercase name? If so, then it's a pragma.
- Is the module a core module? If not, it unlikely to be a pragma.
Based on the last two points, you'll be almost guaranteed to be correct if you simply check the module name against the list of core modules that are pragmas.
Update: My post and the list Mutant posted discuss lexically scoped pragmas. The list I posted above define the term "pragma" more loosely. I'm not sure which one you want.
| [reply] [d/l] [select] |
|
|
>I'm not sure which [list] you wanted
Probably the list you posted. It's a question of what the user will want to see — why does anybody want to see a graphic map of the dependencies between a bunch of modules, anyways? Usually, to answer the question "If I muck around with this module, what else gets broken?" Hardly anybody is going to be changing the strict or warnings code. A bunch of map lines showing that all the modules depend on them is unhelpful. So I want to be able to exclude (at least as a default) all the modules that people are unlikely to be mucking with. Pretty much everything in your 'looser' def of pragma fills that bill.thanks, throop
| [reply] |
Re: Is it a pragma or a module?
by Mutant (Priest) on Dec 14, 2006 at 16:59 UTC
|
Since there aren't many pragmas (see the full list) you might be able to just hardcode the list in.
(Actually, not sure that list is complete, because it doesn't contain 'warnings', but you can probably find a list fairly easily). | [reply] |
Re: Is it a pragma or a module?
by perrin (Chancellor) on Dec 14, 2006 at 17:56 UTC
|
Unfortunately, a number of people have broken the conventions and released their non-pragma modules to CPAN with all lowercase names, just because they like the way it looks. That means you pretty much have no choice but to hard-code the list of real pragmas. | [reply] |
|
|
...and then put it on CPAN as a pragma, or would that be a module?
| [reply] |
|
|
Only code that is part of the core and maintained as part of perl itself can be properly called a pragma. Otherwise it's just a module getting uppity.
| [reply] |
Re: Is it a pragma or a module?
by halley (Prior) on Dec 14, 2006 at 20:39 UTC
|
It's kind of like deciding what is a medicine and what is simply an herbal remedy. A pragma, in concept, means that it changes the actual core Perl language in some way so that it is better able to work with you on expressing a solution. A non-pragma module, in concept, offers you a set of tools separate from the actual Perl language, with which you build your solution. Clear enough for you? Sometimes, me neither.
-- [ e d @ h a l l e y . c c ]
| [reply] |
|
|
| [reply] |
|
|
| [reply] |
Re: Is it a pragma or a module?
by crashtest (Curate) on Dec 14, 2006 at 22:29 UTC
|
... list of the most popular pragmas (pragmae?) and ...
It's Greek. The plural is "pragmata". The "ae" ending forms a plural for a certain class of Latin words.
| [reply] |
Re: Is it a pragma or a module?
by jbert (Priest) on Dec 15, 2006 at 14:09 UTC
|
If I were in your shoes (writing a module to recursively scan modules and wanting to ignore some), I'd provide four modes of operation:
- "Ignore commonly used" - this is where you hardcode a list of modules/pragmata to exclude from your processing.
- "Ignore supplied list only" - allow the caller to replace the list of modules to ignore
- "Ignore commonly used list plus supplied list" - allow the caller to add to the list of modules to ignore.
- Process everything (a special case of 2 - where the ignore list is empty)
And you might want to make the "supplied list" accessible as part of your API too, so that calling code can make educated decisions about what to do.
| [reply] |