home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


defined

defined 
expr

Returns a Boolean value saying whether the scalar value resulting from expr has a real value or not. If no argument is given, defined checks $_ .

A scalar that contains no valid string, numeric, or reference value is known as the undefined value, or undef for short. Many operations return the undefined value under exceptional conditions, such as end of file, uninitialized variable, system error, and such. This function allows you to distinguish between an undefined null string and a defined null string when you're using operators that might return a real null string.

You can use defined to see if a subroutine exists, that is, if the subroutine definition has been successfully parsed. However, using defined on an array or a hash is not guaranteed to produce intuitive results, and should be avoided.