Click here to get back home

proper way to include constants; as module or include file?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
proper way to include constants; as module or include file? David Tiberio 10-24-2004
Posted by David Tiberio on October 24, 2004, 10:50 pm
Please log in for more thread options
I am developing a new perl module that uses constants with regular
expressions. What is the proper way to offer this file?

For example, my perl file is compromised of constants such as the
following:

use constant REGEX_SHELL_DATE =>
b(b(b(Sun|Mon|Tue|Wed|Thu|Fri|Sat)b|b(Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)b)bsb(b(d|[
0]d|[1][012])b|b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)b|b(January|February|March|April|May|June|July|August|September|October|November|December)b)bs(d)sb(b([
01]d|2[0-3])b:b([0-5]d)b:b([0-5]d)b)bsb([A-Z])bsb(d|d)b)b;

And a programmer would use my constants like so:

my $date = "Mon Oct 25 11:59:13 EDT 2004";
print $1 if $date =~ /@/;
exit();

Should my file, containing constants, be a module or some sort of
include file? How would the programmer "include" the file? I tried it
as a module, but constants are not naturally accessible from a program
calling the module.


Posted by Jim Keenan on October 26, 2004, 1:49 am
Please log in for more thread options
David Tiberio wrote:

> I am developing a new perl module that uses constants with regular
> expressions. What is the proper way to offer this file?
>
> For example, my perl file is compromised of constants such as the
> following:
>
> use constant REGEX_SHELL_DATE =>
>
b(b(b(Sun|Mon|Tue|Wed|Thu|Fri|Sat)b|b(Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)b)bsb(b(d|[
>
0]d|[1][012])b|b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)b|b(January|February|March|April|May|June|July|August|September|October|November|December)b)bs(d)sb(b([
>
01]d|2[0-3])b:b([0-5]d)b:b([0-5]d)b)bsb([A-Z])bsb(d|d)b)b;
>
> And a programmer would use my constants like so:
>
> my $date = "Mon Oct 25 11:59:13 EDT 2004";
> print $1 if $date =~ /@/;
> exit();
>
> Should my file, containing constants, be a module or some sort of
> include file? How would the programmer "include" the file? I tried it
> as a module, but constants are not naturally accessible from a program
> calling the module.

Please check out the documentation for CPAN distribution Regexp::Common.
You may find that it already provides the functionality you need. If
it doesn't, then continue work on your own module.

jimk


Similar ThreadsPosted
How to include a connection file in perl December 2, 2006, 3:11 pm
Customizing include path with CPAN install November 22, 2004, 9:46 am
Install Picks Wrong Dir for Include Files February 17, 2005, 8:13 pm
Sort::Maker: (Notes) The plain and the orcish don't include the "init_code" December 14, 2006, 7:32 am
module with commonly used constants? February 9, 2006, 1:02 am
advice needed on using proper perl graphics module(s) November 4, 2004, 1:02 pm
Looking for a file transfer module NOT ftp May 9, 2006, 11:12 pm
Error in delete file using NET:FTP module February 10, 2006, 6:31 pm
Is there a module to help me to send/receive msg and file with MSN message? May 12, 2005, 2:03 am
Is there a module that can check if user "foo" may read a file? August 5, 2005, 3:59 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap