=begin metadata

Name: mimedecode
Description: extract MIME attachments in uudecode-like manner
Author: Nick Ing-Simmons, nick@ni-s.u-net.com

=end metadata


use v5.12.0;
use Getopt::Std;

	my $external_module = 'MIME::Parser';
	my $rc = eval "require $external_module; $external_module->import; 1";
	die "This program needs the $external_module module.\n" unless $rc;

{package PerlPowerTools::MIME::Parser;
push @INC, 'MIME::Parser'; # this is old school so -c doesn't complain

sub new_body_for
  my ($parser,$head) = @_;
  my $outname = $head->recommended_filename;
  if (defined $outname)
    return MIME::Body::File->new($parser->output_path($head));
    return MIME::Body::Scalar->new;


my %opt = ( 'd' => '.' );


my $parser = PerlPowerTools::MIME::Parser->new;

if (@ARGV)
  foreach my $file (@ARGV)
    my $entity = $parser->parse_in($file);
  my $entity = $parser->read(\*STDIN);


=head1 NAME

mimedecode - extract MIME attachments in uudecode-like manner


  mimedecode [-d directory] < file

  mimedecode [-d directory] file...


C<mimedecode> processes mail files using B<MIME::Parser> module.
It handles "multipart" messages and saves "attached" files
(i.e. parts with suggested file names) to their suggested names
in the directory specified after C<-d>, or the current directory if
C<-d> is not given.

=head1 BUGS

It needs the module installed.

Should probably consider more of headers in deciding if it really
is a useful attachment.

=head1 AUTHOR

Slapped together by Nick Ing-Simmons <nick@ni-s.u-net.com>