[EMAIL PROTECTED] wrote: > Hi, > > What's the preferred waying of doing things... > > if ($var eq '') > > or > > if (defined $var) > > I assume they both mean pretty much the same thing? >
No, defined is used to tell if the value is undef or not. undef is a special scalar value, it is treated as '' when used as a string and 0 when used as a number. If warnings are turned on you will get a warning when it used in the RHS of an expression. perldoc perlsyn (read the section on 'Declarations') e.g. $var; print "Is undef" if (!defined($var)); #prints Is Undef $var = ''; print "value exists" if (defined($var)); #prints value exists $var eq '' should be used for checking empty strings. > > Tristan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]