foreach (@closefamilymember) { $gift = perfectgift $_; buy($gift); push @boughtengifts, $gift; } foreach (@boughtengifts) { $box->pack($_); } foreach (@notsoclosemember) { $gift = perfectgift $_; if (!box->pack($gift)) { $gift = giftthatwillfitinfreespace $_; $box->pack($gift); } } box->mail();