Exploding check commands batman ...

Darren Dunham ddunham at taos.com
Fri Jul 1 22:43:35 CEST 2005


> In strict mode uninitialized variables cannot be used in comparisons.
> So if somebody does manage to do something that results in a variable
> holding an option being uninitialized, as opposed to being initialized
> with the null string, things break.  Outside of strict mode an
> uninitialized variable is false in a boolean context, 0 in a numeric
> context and the null string in a string context; in strict mode all you
> can do with an unitialized variable without causing an error is assign
> to it. 

Perl's strict deals with "compile time" issues like lexical scoping
(declaration rather than initialization).  It doesn't do anything with
run time issues like undefined variables.  That would be noticed by
warnings, not strict.

It certainly doesn't preclude comparisons with the undefined value or
uninitialized variables.  In no case is it an error.

$ perl -le 'use strict;my $v;if(5==$v){print "equal"}else{print "not equal";}'
not equal
$ perl -le 'use warnings;my $v;if(5==$v){print "equal"}else{print "not equal";}'
Use of uninitialized value in numeric eq (==) at -e line 1.
not equal

-- 
Darren Dunham                                           ddunham at taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list