Re: [Boston.pm] perl constants

2013-03-05 Thread Drew Taylor
Neil Bowers has a review of 20+ constant modules. Sometimes I was there a few less ways to do it! :) http://neilb.org/reviews/constants.html On Wed, Mar 6, 2013 at 9:02 AM, Uri Guttman wrote: > On 03/05/2013 04:28 PM, Wayne Tackabury wrote: > >> >> well, you could write your own import method

Re: [Boston.pm] perl constants

2013-03-05 Thread Uri Guttman
On 03/05/2013 05:02 PM, Mike Stok wrote: http://mail.pm.org/pipermail/belfast-pm/2004-February/002482.html might be interesting. schwern's code uses @EXPORT and Exporter to do the actual exporting. it could also be modified to take a list of key/val pairs so you could call it like: econs

Re: [Boston.pm] perl constants

2013-03-05 Thread Mike Stok
http://mail.pm.org/pipermail/belfast-pm/2004-February/002482.html might be interesting. On 2013-03-05, at 4:22 PM, Uri Guttman wrote: > On 03/05/2013 12:24 PM, Greg London wrote: >> >>> the one thing that >>> seems a bit odd is that Greg's example didn't have separate packages for >>> the sepa

Re: [Boston.pm] perl constants

2013-03-05 Thread Uri Guttman
On 03/05/2013 04:28 PM, Wayne Tackabury wrote: well, you could write your own import method. actual exporting is trivial - ... sounds like a module to do this (Constant::Export) might be useful. Hey, sounds like the agenda to the next PM meeting! :) i found this which is not exactly the s

Re: [Boston.pm] perl constants

2013-03-05 Thread Uri Guttman
On 03/05/2013 04:28 PM, Wayne Tackabury wrote: well, you could write your own import method. actual exporting is trivial - ... sounds like a module to do this (Constant::Export) might be useful. Hey, sounds like the agenda to the next PM meeting! :) doable. i can outline in more detail the

Re: [Boston.pm] perl constants

2013-03-05 Thread Uri Guttman
On 03/05/2013 12:24 PM, Greg London wrote: the one thing that seems a bit odd is that Greg's example didn't have separate packages for the separate files yeah, I did something like this a long time ago, and can't remember how I did it exactly. Basically, I pulled the file in like a #include

Re: [Boston.pm] perl constants

2013-03-05 Thread Greg London
> the one thing that > seems a bit odd is that Greg's example didn't have separate packages for > the separate files yeah, I did something like this a long time ago, and can't remember how I did it exactly. Basically, I pulled the file in like a #include so no enclosing package because I wanted

Re: [Boston.pm] perl constants

2013-03-05 Thread Uri Guttman
On 03/05/2013 11:01 AM, Bill Ricker wrote: Damian Conway in PBP ch.4 argues for 'use Readonly;' rather than 'constant'. first off, greg needs to export the symbols as someone has said. several ways to do that including the classic Exporter module. as for Readonly vs use constant, they are d

Re: [Boston.pm] perl constants

2013-03-05 Thread David Larochelle
What Bill said. On Tue, Mar 5, 2013 at 11:01 AM, Bill Ricker wrote: > Damian Conway in PBP ch.4 argues for 'use Readonly;' rather than > 'constant'. > > > On 3/5/13, Andrew Langmead wrote: > > On Tue, 2013-03-05 at 08:12 -0500, Jordan Adler wrote: > >> Using the constant pragma is best. Perldo

Re: [Boston.pm] perl constants

2013-03-05 Thread Bill Ricker
Damian Conway in PBP ch.4 argues for 'use Readonly;' rather than 'constant'. On 3/5/13, Andrew Langmead wrote: > On Tue, 2013-03-05 at 08:12 -0500, Jordan Adler wrote: >> Using the constant pragma is best. Perldoc constant. > > the constant pragma (or Readonly) does express intent better than >

Re: [Boston.pm] perl constants

2013-03-05 Thread Andrew Langmead
On Tue, 2013-03-05 at 08:12 -0500, Jordan Adler wrote: > Using the constant pragma is best. Perldoc constant. the constant pragma (or Readonly) does express intent better than prototyped subroutines named with uppercase letters that return constant values. That doesn't apply to the problem here.

Re: [Boston.pm] perl constants

2013-03-05 Thread Jordan Adler
Using the constant pragma is best. Perldoc constant. Sent from my iPhone On Mar 5, 2013, at 7:59 AM, Mike Stok wrote: > Don't you need to export the constant? > > Maybe this isn't the modern way to do it, but: > > ratdog:tmp mike$ cat constant1.pm > package constant1; > > require Exporter; > @

Re: [Boston.pm] perl constants

2013-03-05 Thread Mike Stok
Don't you need to export the constant? Maybe this isn't the modern way to do it, but: ratdog:tmp mike$ cat constant1.pm package constant1; require Exporter; @ISA = qw( Exporter ); @EXPORT = qw( NUM_MUSKETEERS ); sub NUM_MUSKETEERS() {3} 1; ratdog:tmp mike$ perl script.pl mod1: 1 mod1: 2 mod1:

[Boston.pm] perl constants

2013-03-05 Thread Greg London
OK, I've been coding since 5am, so I assume I'm just tired, but I can't figure this out. I have a bunch of perl constants that I put in a module. I'm trying to use that module in two different places. I'm getting an error: Bareword "CONSTANTNAME" not allowed while "strict subs" in use Here's a