Using 'if exists' to check the entry in hash : exists « Hash « Perl






Using 'if exists' to check the entry in hash

      
#!/usr/bin/perl -w

use strict;

my %where = (
     A => "AA",
     B => "BB",
     C => "CC",
     D => "DD"
);

print "A!\n"  if exists $where{A};

   
    
    
    
    
    
  








Related examples in the same category

1.Determine if a particular key exists
2.If an entry exist
3.The exists function returns true if a hash key (or array index) has been defined, and false if not.
4.To tell if a given key name exists in a hash, you can use the exists operator.