return $ct{'text/plain'} if exists $ct{'text/plain'}; return $ct{'text/html'} if exists $ct{'text/html'}; return $parts[0] if $which =~ /text/; return $parts[1] if $which =~ /html/; #### my $ct = $which eq 'html' ? 'text/html' : 'text/plain'; return $ct{$ct} if exists $ct{$ct}; # Fall back to plain text or HTML return $ct{'text/plain'} if exists $ct{'text/plain'}; return $ct{'text/html'} if exists $ct{'text/html'}; # Fall back to whatever's first return $parts[0]; #### $ct{$_->content_type} = $_ for @parts; #### $ct{$_->content_type} ||= $_ for @parts;