On Wed, 20 Feb 2002, Daniel Falkenberg wrote: > Just wondering how I check if a variable contains nothing or not. I > thought it was something like the following... > > if ( $string eq '' ) { > print "String contains nothing"; > } else { > print "The string contains the following: $string"; > }
Yes, that is correct, if the string is an emoty string, as opposed to being undefined (never assigned to). An empty string also yields boolean false, so you can say: if(!$string) { #... } else { #... } This is also different from an undefined or uninitialized string, for which you should do: if(!defined($string)) { #... } else { #... } -- Brett http://www.chapelperilous.net/ ------------------------------------------------------------------------ There are more dead people than living, and their numbers are increasing. -- Eugene Ionesco -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]