I have the following code:
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
my $site = "test.com";
my $data = {
"test" => 1
};
my $user = defined($data->{addons}->{$site}->{username}) ? $data->{addons}->{$site}->{username} : "nothing";
print Dumper($data);
The result:
$VAR1 = {
'test' => 1,
'addons' => {
'test.com' => {}
}
};
As you can see the check if the user is defined in the nested structure actually creates an empty keys. My questing is how to check the hashref without defining the keys.