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.
In reply to Re: Barewords and equality tests
by dave_the_m
in thread Barewords and equality tests
by punkish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |