in reply to Coding Perl With Style

Sounds like you need to look into OOP - check out perltoot and look in Tutorials here.

Now, is OOP going to solve all of your problems? No. Check out Big Ball of Mud. OOP is just the tool, the results depend upon the coder wielding it.

Second question - yes, it will remain a 'constant' and you will get a run time error if you try and change it. And i didn't know why until wog said it. ;)

To elaborate more, this is a way i would do it:

package Foo; use constant BAR => 27; sub bar { return BAR }; 1;
Providing accessor methods tends to keep folks from trying to change the guts, but not always.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)

Replies are listed 'Best First'.
Re: (jeffa) Re: Coding Perl With Style
by Biker (Priest) on Nov 27, 2001 at 13:43 UTC

    When I write a 'getter' of a static value, not used by other methods in the same module, I tend to write:

    package Foo; sub bar {27;} 1;


    If more than one method in my module needs this value, then I let the other methods all use the first method, the one having the value hard coded (in this case 'bar').

    Any pros and cons to this approach?

    f--k the world!!!!
    /dev/world has reached maximal mount count, check forced.