Skip Menu |

This queue is for tickets about the enum CPAN distribution.

Report information
The Basics
Id: 421
Status: resolved
Priority: 0/
Queue: enum

People
Owner: Nobody in particular
Requestors: iamvhl [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: cannot require enum from another file
If I put this in a file 1: use enum qw(BUILDS DEV QA); 1; Then in file 2.pl I will write #!/usr/bin/perl -w require(1); print BUILDS; It will not see the enum. Thus if I enum in one file, I cannot include it in another file. If I am wrong, please let me know how I can do it. thx!
It's quite a while since you raised this ... :-) The enum module doesn't export the symbols for you. The basic way to do this is as follows. Let's say you have a class DaysOfTheWeek, in DaysOfTheWeek.pm, and you want it to export the symbols for the days of the week: package DaysOfTheWeek; use parent qw(Exporter); use enum qw(Mon Tue Wed Thu Fri Sat Sun); our @EXPORT = qw(Mon Tue Wed Thu Fri Sat Sun); 1; That has duplication of the days of the week, which isn't good ("don't repeat yourself"), so you could rewrite that as: package DaysOfTheWeek; BEGIN { our @EXPORT = qw(Mon Tue Wed Thu Fri Sat Sun); } use parent qw(Exporter); use enum @EXPORT; 1; You have to define @EXPORT in a BEGIN block, so it's available for the 'use enum', which runs at compile time.