Questions about this topic? Sign up to ask in the talk tab.

Perl/Basics/Boolean Logic/Helper Natives

From NetSec
Revision as of 01:25, 19 July 2012 by Chantal21I (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

These helper natives are boolean statements that assist with the determination of the existence of or the defining of a variable.

exists

The exists native applies specifically to hashes and hash references.

print "This user has an age.\n" if exists $user->{'age'};
 

defined

The defined native determines if a scalar value is defined:

 
print "We received a response from the server.\n" if defined $response;
 

undef

The undef native determines if a scalar value is un-defined:

 
print "We received a response from the server.\n" unless undef $response;