Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
package test0; $data = { k0 => [ 1,2,3, ], k1 => [ 1,2,3, ], }; return (__PACKAGE__); 1;
Question(s) :
- is there no way to determine
the name of the package without the use of the return?
- is there a way to determine the name of the hash
that is in the package?
#! use strict; use warnings; my $pmfile = shift @ARGV; my $pm = require "$pmfile"; no strict 'refs'; my $pckg = ${ $pm . "::data" }; use strict;
Questions :
- is my use of symbolic reference correct/appropriate?
- as you can see, the name of the package's data
has to be hardcoded. is there an alternative?
Edited by Chady -- minor formatting, code tags.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: modules as data files
by dragonchild (Archbishop) on Oct 08, 2005 at 02:37 UTC | |
by Anonymous Monk on Oct 08, 2005 at 03:05 UTC | |
by dragonchild (Archbishop) on Oct 10, 2005 at 04:18 UTC | |
|
Re: modules as data files
by ioannis (Abbot) on Oct 08, 2005 at 06:51 UTC | |
by Anonymous Monk on Oct 10, 2005 at 19:02 UTC |