If there's no cart, you use an empty list here. Then you iterate over the empty list and, ultimately, return undef. You could save a little cognitive processing by just saying `my $cart = ... or return;`