fork download
  1. use strict;
  2. use warnings;
  3.  
  4. my %hash = ('a' => 'b', 'c' => 'd');
  5.  
  6. sub check {
  7. my ($idx) = @_;
  8. if (defined $hash{$idx}) {
  9. print "$idx is defined";
  10. } else {
  11. print "$idx isn't defined"
  12. }
  13. }
  14.  
  15. check($hash{'a'});
  16. check($hash{'x'});
  17. check($hash{'b'});
  18.  
Success #stdin #stdout 0s 3740KB
stdin
Standard input is empty
stdout
b isn't defined isn't defined isn't defined