Hello,
I am trying to better understand symbol tables wrt packages. I am working with a .pm and a .pl along the following lines:
a.pm:
package a;
$fred = 'test';
b.pl:
#!/bin/perl
use strict;
use a;
print "$fred\n";
At its basest, I would like to print $fred without the use of Exporter. I am working with the notion of a shared globals file, and I want to share this between multiple packages without the overhead and hassle of @EXPORT and the whole Exporter module.
It seems like there should be a way to import the symbol table via a simple mass typeglob, but as of this writing I have not been able to figure out how. I can get as far as being able to print $main::fred by doing '*main = *a::;', but I want to get this down even more (ie to being able to simply print $fred).
I can do this long hand but I'm considering globals files of 1000s of globals potentially. More of a theoretical exercise than anything.
Thanks in advance.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.