in reply to Barewords and equality tests
Q1. What is this use of barewords? I almost feel compelled to single quote all the words in UPPERCASE above. Should this not be 'SERVICE_STOPPED' etc.? And won't this fail under use strict?It's Perl's rather clumsy attempt to allow constants. SERVICE_STOPPED is actually a zero-argument function that returns a value, and which the perl interpreter optimises away at compile-time. See also 'use constant'.
Q2. Are the UPPERCASE words above just proxy for numbers?Dunno. That depends on the particular module that defines the constant.
Q3. (this one is the style-related question) I feel the urge to reverse the above tests as inPersonally I prefer this too.if( $State == SERVICE_STARTING )
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Barewords and equality tests
by Old_Gray_Bear (Bishop) on Dec 29, 2004 at 23:03 UTC |