Question: Python's counterpart of Perl's hashes are `dict` (dictionary) objects. 

If `d` is a Python `dict`, then the expression

```
d.get(key, default)

```

...evaluates to `d[key]` if it exists, and to `default` otherwise.

Does Perl have any support for the same idea, beyond the ternary expression

```
exists $h{$key} ? $h{$key} : $default

```

?

Answer: 
You can either use the ternary expression you already know

```
my $value_or_default = exists $h{$key} ? $h{$key} : $default

```

or

```
my $value_or_default = $h{$key} // $default ;

```

The `//` is the **defined or** operator.

It depends on your data and needs if you want to swap to the defined-or-operator. The difference is when you have a key with a undefined value you will get different results.

```
my %hash = ( key1 => undef ,
             key3 => 1 ) ;
my $default = 42 ;

foreach my $test ( qw(key1 key2 key3) ) {
  printf "%s => %s exists\n%s => %s defined-or\n\n" ,
         $test ,
         exists $hash{$test} ? $hash{$test} : $default ,
         $test ,
         $hash{$test} // $default ;
}

```

this results in:

```
Use of uninitialized value $hash{"key1"} in printf at x.pl line 11.
key1 =>  exists
key1 => 42 defined-or

key2 => 42 exists
key2 => 42 defined-or

key3 => 1 exists
key3 => 1 defined-or

```

For *key1* the key exists but the value is undefined and therefor perl issues the warning.
You can use the defined-or operator: `//`
And if you want the default value to be part of the structure set the key 'default':

```
my %h = (default => 'Some default value');
say $h{'notSet'} // $h{'default'};

```