FWIW, wouldn't a constant that changes, or can be changed, violate the very definition of a constant? I normally call them variables. ;)
................................ Kind regards Glenn Deans Sr. Systems Engineer Siemens Business Services, Inc. Bellefontaine, OH USA -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jan Dubois Sent: Wednesday, December 07, 2005 1:51 PM To: [EMAIL PROTECTED]; [email protected] Subject: RE: An inconstant constant? On Wed, 07 Dec 2005, Jan Dubois wrote: > Or you can define a normal subroutine: > > sub DATA_COLS () { $os eq 'X') ? 6 : 7 } > > assuming $os will not change during the lifetime of your program. I just realize that I should have emphasized the importance of specifying the empty prototype for the "constant" function. This makes a big difference when you use it without parentheses: my $foo = DATA_COLS + 1; will be compiled as my $foo = DATA_COLS() + 1; If you didn't specify the prototype: sub DATA_COLS { $os eq 'X') ? 6 : 7 } then it would be compiled as my $foo = DATA_COLS(+ 1); effectively ignoring the "+ 1" part. Demo: C:\>perl -we"sub foo {5}; print foo + 1" 5 C:\>perl -we"sub foo () {5}; print foo + 1" 6 Cheers, -Jan _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
