I have spent the past few days working with Win32::Daemon. I have been using code (from the docs and examples provided) that looks like so
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?while( SERVICE_STOPPED != ( $State = Win32::Daemon::State() ) ){ if( SERVICE_STARTING == $State ) {
Q2. Are the UPPERCASE words above just proxy for numbers? For example, in the situation above, the State() returned is actually a number. Of course, having the -w switch on complains that
Argument "SERVICE_STARTING" isn't numeric in numeric eq (==) at ...
Q3. (this one is the style-related question) I feel the urge to reverse the above tests as in
since I am used to testing the value that a variable holds against certain "measures" that are fixed as inif( $State == SERVICE_STARTING )
if ($color eq 'red') { print 'angry'; } elsif ($color eq 'green') { print 'money'; } elsif ($color eq 'blue') { print 'sad'; }
I guess this is new idiom for me, and I need to understand what is going on here.
In reply to Barewords and equality tests by punkish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |