# create a MIME::Parser object to # extract any attachments found within. my $parser = new MIME::Parser; $parser->output_dir( $savedir ); my $entity = $parser->parse_data($msg); # extract our mime parts and go through each one. my @parts = $entity->parts; foreach my $part (@parts) { # determine the path to the file in question. my $path = ($part->bodyhandle) ? $part->bodyhandle->path : undef; print "This is the $path \n"; #right here if it doesnt have the brackets it will give the correct file name if it does it will come back -1.pdf or some other count