[Israel.pm] constants

sawyer x xsawyerx at gmail.com
Sun Sep 6 01:08:52 PDT 2009


On Sun, Sep 6, 2009 at 10:54 AM, Berler Chanan <bc.other at gmail.com> wrote:
>
> Hi All,

Hi.

> Let me start by saying for the X times, I am not using strict / warnings due
> to my manager who decided it as policy
> (since he wrote all the code without it, and adding it will only make things
> worse...all variables declaring and stuff
> he wrote in the past)

I can understand your tricky situation, it doesn't sound like much fun.
However, another tricky situation would be for anyone that wants to
help you (and I can promise you, there are many of those). The trick
is trying to figure out the problem without being able to eliminate
problems that can be the cause of it. It's like figuring out a leak
without being able to fix the pipes. It might be the pipes but you
cannot fix them in order to see if it's something else. When you use
strict, you eliminate common errors that have a good chance of being
the reason. I avoid helping people who don't (and can't) use strict
because it's a headache. Be prepared to have some of your questions
subtly ignored because no one wants to play in the swamp. :)

> As for pt / mm / in as future to be reserved words well, I will then refer
> you to the article I used for creating PDF files:
> http://rick.measham.id.au/pdf-api2/
> Where he was using these words, my idea came when I wanted to create a
> common module for all my reports with same
> constants....
>
> As for pt / mm / in as being Bareword, I understood it when I run the little
> code I wrote...but still I need these constants
> to be shared with the other files

"constant" has its issues. I personally use Readonly. Try this:
----- const.pm
use Readonly;
Readonly $pt => 1;
1;
----- const.pl
use const;
print "$pt\n";
--------

Also, if you use Readonly, you can install Readonly::XS which speeds it up.
I hope this helps.

Good luck,
Sawyer.


More information about the Perl mailing list