[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

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 m...@stok.ca 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

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 Bill Ricker
Damian Conway in PBP ch.4 argues for 'use Readonly;' rather than 'constant'. On 3/5/13, Andrew Langmead a3n8cch...@snkmail.com 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

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 bill.n1...@gmail.com wrote: Damian Conway in PBP ch.4 argues for 'use Readonly;' rather than 'constant'. On 3/5/13, Andrew Langmead a3n8cch...@snkmail.com wrote: On Tue, 2013-03-05 at 08:12 -0500, Jordan Adler wrote: Using the

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

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 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 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

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 u...@stemsystems.com 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

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:

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 u...@stemsystems.com wrote: On 03/05/2013 04:28 PM, Wayne Tackabury wrote: well, you could write your