$x = shift; $x = defined $x ? $x : 4; # Or with the "defined or" patch $x = shift // 4; # Or check if there is anything left on @_ and shift if there is $x = @_ ? shift : 4;