my $suffix = do { my $result; given ($type) when ("csv") { $result = "txt" } when ("xml") { $result = "xml" } ... } $result };