Help for this page

Select Code to Download


  1. or download this
    $a = "default" unless defined $a;
    $h{key} = "value" unless exists $h{key};
    
  2. or download this
    $a = "default" unless $a;
    $h{key} ||= "value";
    
  3. or download this
    my $a_val = defined $a ? $a : "default";
    my $h_key_val = exists $h{key} ? $h{key} : "value";
    
  4. or download this
    my $a_val     = $a || "default";
    my $h_key_val = $h{key} || "value";
    
  5. or download this
    sub do_stuff
    {
    ...
        # now join the two, giving precedence to %raw_args
        my %args = ( %default_args, %raw_args );
    }