my $attached = ($code) ? "attach_path => '$file_name',attach_filena +me => '$file_name',attach_type => 'application/txt'," : {}; my $success = email( { to => $email, from => $from, from_name => $name, subject => $subject, body => $body, %$attached } );