fork download
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. my %a = ('a' => 1, 'b' => 2);
  6.  
  7. if (exists $a{'c'}) {
  8. print "exists before\n";
  9. } else {
  10. print "not exists before\n";
  11. }
  12.  
  13. if (defined $a{'c'}) {
  14. print "defined\n";
  15. } else {
  16. print "not defined\n";
  17. }
  18.  
  19. if (exists $a{'c'}) {
  20. print "exists after\n";
  21. } else {
  22. print "not exists after\n";
  23. }
  24.  
  25. for my $i(keys(%a)) {
  26. print $i . "\n";
  27. }
  28.  
Success #stdin #stdout 0s 3740KB
stdin
Standard input is empty
stdout
not exists before
not defined
not exists after
a
b