Using 'defined' keyword in if statement : defined undef « Language Basics « Perl






Using 'defined' keyword in if statement

    

#!/usr/bin/perl -w

use strict;

my ($a, $b);
$b = 10;

if (defined $a) {
    print "\$a has a value.\n";
}
if (defined $b) {
    print "\$b has a value.\n";
}

   
    
    
    
  








Related examples in the same category

1.Using undef to represent an unusual condition.