Why should 'use Fields' throw an error? It's included in the file.
The copy of Fields in memory will have priority over the disk version with 'use mem'.
Edit: Oh -- you are not talking about my version... nevermind.
| [reply] [d/l] [select] |
> Why should use Fields throw an error? It's included in the file.
but not in %INC
See require and
perlvar#%25INC :
> The hash %INC contains entries for each filename included via the do, require, or use operators. The key is the filename you specified (with module names converted to pathnames), and the value is the location of the file found. The require operator uses this hash to determine whether a particular file has already been included.
| [reply] [d/l] |
But Fields had a "use mem".
mem tells perl to use the in-memory copy of Fields (via adding it to the appropriate perlvar).
I put a "use mem" inside any of my modules that need to be used in the same file. I also add a '1' at the end of the module, so if I later cut/paste the module out to a separate file, it shouldn't require modification.
I also, often, use mem to insert "1-liner" BEGIN-needing assignments, as it looks a bit cleaner (IMOpinion), than equivalent the equivalent 1-liner using BEGIN{}. For multiple lines or, especially, when needing code, I tend more toward using an actual BEGIN block these days.
I could use any module that ignores it's parameters for the same purpose, but mem guarantees it won't pay attention to their content, so its short and convenient. Ikegami used an equivalent assignment to some perlvar to do the same, but I often forget the var (or confuse it with INCLUDE), thus find mem easier to remember. :-| (*str8 face*)
| [reply] [d/l] [select] |