note
BrowserUk
<blockquote><i></i></blockquote>
<p>Ignoring whether <i>"you should be doing this"</i>; here's one way it could be done:
<p>The PM file:<code>
package MyObjs;
use strict;
use warnings;
use enum qw[ :MOError=0 One Two Three Four Five ];
sub import {
my $self = shift;
my $caller = caller();
for( @_ ) {
if( /^:MO/ ) {
no strict; no warnings;
*{ "$caller\:\:MOError$_" } = *{ "MOError$_" } for qw[ One Two Three Four Five ];
}
elsif( /^:O1/ ) {
no strict; no warnings;
*{ "$caller\:\:O1Error$_" } = *{ "Object1\:\:O1Error$_" } for qw[ One Two Three Four Five ];
}
elsif( /^:O2/ ) {
no strict; no warnings;
*{ "$caller\:\:O2Error$_" } = *{ "Object2\:\:O2Error$_" } for qw[ One Two Three Four Five ];
}
else {
die "Unknown export $_";
}
}
}
package Object1;
use enum qw[ :O1Error=100 One Two Three Four Five ];
package Object2;
use enum qw[ :O2Error=200 One Two Three Four Five ];
1;
</code>
<p>And a script that imports from that:<code>
#! perl -slw
use strict;
use MyObjs qw[ :MO :O1 :O2 ];
print for MOErrorOne, O1ErrorThree, O2ErrorFive;
__END__
C:\test>t-MyLib.pl
0
102
204
</code>
<p>NOTE: The use of the [mod://enum] module is not germane to this working. Any subs can be exported including normal subs and those generated by [mod://constant] etc.
<div class="pmsig"><div class="pmsig-171588">
<hr />
<font size=1 >
<div>With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'</div>
<div>Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.</div>
<div>"Science is about questioning the status quo. Questioning authority". </div>
<div>In the absence of evidence, opinion is indistinguishable from prejudice.
<p align=right> [http://thebottomline.cpaaustralia.com.au/|RIP Neil Armstrong]</p></div>
</font>
</div></div>;
997244
997244