in reply to Re^3: How to import constants from another perl script
in thread How to import constants from another perl script

and that's the reason I prefer Readonly instead. The constants end up being perl variables that you can't change. I find $SomeConstant more obvious than SomeConstant().

... but maybe that's just me.

Replies are listed 'Best First'.
Re^5: How to import constants from another perl script
by Anonymous Monk on Nov 01, 2010 at 14:24 UTC
    Well, if you do it properly (i.e. use BEGIN {} in this case), you don't need the parens (except in some rare cases where disambiguation is needed), and you have the added performance benefit of the subroutines being optimized away.

    Of course you can't interpolate subroutine calls in double quoted strings... which is a clear disadvantage if constant. But Readonly, OTH, is slow (because it relies on tied magic), and may occasionally cause other strangeness (for an example, see runtime problem; elusive error).