`$x = foo unless $x` is probably better written as `$x ||= foo` or maybe even `$x //= foo`.