Hi guys,
I am writing a program which is going to create an object of a perl class and uses a bunch of constants. I don't want to export those constants because I can access them through my class object. I was going through the constant man page and saw that perl replaces constant values by their inline
subroutine calls.
My question is: Is using constants slower than using variables? If yes, is there a better way to use constants?
I am asking this because my program is going to be a sendmail milter (a program which is called for each stage of an SMTP session to decide whether the message is acceptable depending on sender, rcpt, etc). It is going to be bombed with SMTP transactions at a very high rate.
A sample snippet of code:
my $logobj = new Merce::Log;
$logobj->log($logobj->PRIORITY, $logobj->MSGTMPL);
I have seen guys using $:: for constants or exporting them but I don't want to do that. You might think I am doing premature optimization but I was curious to know.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.