fork(2) download
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my %hash = ( LEVEL_1_KEY => {
  5. LEVEL_2_KEY => "myval"
  6. }
  7. );
  8.  
  9. if (defined $hash{LEVEL_1_KEY}{LEVEL_2_KEY}){
  10. print "Inside the if block\n";
  11. }
  12.  
  13. #Now with var
  14. my $var = "LEVEL_1_KEY";
  15. if (defined $hash{$var}{LEVEL_2_KEY}){
  16. print "Inside the if block again";
  17. }
Success #stdin #stdout 0s 3740KB
stdin
Standard input is empty
stdout
Inside the if block
Inside the if block again