sub attach_file { my $self = shift; my $body_arg = shift; my $name = undef; my $body = undef; # Support IO::All::File arguments if ( Params::Util::_INSTANCE($body_arg, 'IO::All::File') ) { $name = $body_arg->name; $body = $body_arg->all; # Support file names } elsif ( defined $body_arg and -f $body_arg ) { $name = $body_arg; $body = _slurp( $body_arg ) or return undef; # That's it } else { return undef; } # Clean the file name $name = File::Basename::basename($name) or return undef; # Now attach as normal $self->attach( $body, name => $name, filename => $name, @_ ); }