pop2messbox.pl

#!/usr/bin/perl
use Mail::POP3Client;
use IO::File;

my $Hostname = $ARGV[0];
my $Username = $ARGV[1];
my $Password = $ARGV[2];
my $Location = $ARGV[3];

if ( defined($Hostname) &&
        length($Hostname) > 0 &&
        defined($Username) &&
        length($Username) > 0 &&
        defined($Password) )
{
        if ( ! -d $Location )
        {
                die(qq{$Location is not a valid directory path});
        }
        else
        {
                my $POP = new Mail::POP3Client(
                                USER     => $Username,
                                PASSWORD => $Password,
                                HOST     => $Hostname,
                                USESSL   => true,
                );

                $POP->Connect() >= 0 || die $POP->Message();
                for ($i = 1; $i < = $POP->Count(); $i++)
                {
                        my $Filename = $Location . ‘/’ . join(’_',$Hostname,$Username,$i) . ‘.eml’;
                        my $Filehandle = new IO::File;
                        open($Filehandle, “>$Filename”);
                        $POP->RetrieveToFile( $Filehandle, $i );
                        close($Filehandle);
                }
                $POP->Close();

        }
}

Its no problem to use…
shell$ mkdir /some/storage/location
shell$ ./pop2messbox.pl pop3.host.com username password /some/storage/location/

Requires…
Mail::POP3Client from CPAN

ldap2xml.pl

#!/usr/bin/perl
use Net::LDAP;
use XML::Simple;

my $XML = XML::Simple->new(NoAttr=>0,
                RootName=>'LDAPDump',
                ForceArray=>1 );

my $LDAP = Net::LDAP->new( $ARGV[0] );

my $Message = $LDAP->bind( $ARGV[1],
                password => $ARGV[2] );

if ( defined($Message) )
{

   $Message = $LDAP->search( base   => “”,
        filter => qq{($ARGV[3])});
        foreach my $Entry ($Message->entries)
        {
                if ( defined($Entry) &&
                        ref($Entry) eq ‘Net::LDAP::Entry’ )
                {
                        print $XML->XMLout($Entry->{asn});
                }
        }

        $Message = $LDAP->unbind;
}

Its no problem to use…
shell$ ./ldap2xml.pl ldap_host "uid=whoever,cn=whatever" password "filter_attribute=value"

Requires…
Net::LDAP from CPAN & XML::Simple from CPAN