Email::Sample - generate sample email for testing


Email-Sample documentation Contained in the Email-Sample distribution.

Index


Code Index:

NAME

Top

Email::Sample - generate sample email for testing

VERSION

Top

Version 0.01

SYNOPSIS

Top

    use Email::Sample;

    my $emailgen = Email::Sample->new();
    ...

    $emailgen->add_valid_domains( [ 'url.com.tw'  , 'google2.com.tw'  ] );

    my @valid_emails = $emailgen->valid_emails( size => 20 );

    my @invalid_emails = $emailgen->invalid_emails();

DESCRIPTION

Top

Email::Sample use Data::Random to generate a bunch of valid or invalid email for testing.

FUNCTIONS

Top

valid_emails

add_valid_domains (ARRAY)

AUTHOR

Top

Cornelius, <cornelius.howl at gmail.com>

BUGS

Top

Please report any bugs or feature requests to bug-email-sample at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Email-Sample. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Email::Sample




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Email-Sample

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Email-Sample

* CPAN Ratings

http://cpanratings.perl.org/d/Email-Sample

* Search CPAN

http://search.cpan.org/dist/Email-Sample/

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Email-Sample documentation Contained in the Email-Sample distribution.
package Email::Sample;

use warnings;
use strict;
use Data::Random qw(:all);
# use Text::Greeking;


our $VERSION = '0.01';

sub new {
    my $class = shift;
    my $self = {};
    return bless $self, $class;
}

my @valid_domains = qw(
    yahoo.com
    gmail.com
);

sub valid_emails {
    my $self = shift;
    my %args = @_;

    $args{size} ||= 10;
    my @emails = ();
    for( 1 .. $args{size} ) {
        push @emails, $self->g_valid_identity() . '@' . $self->get_random_valid_domain;
    }
    return \@emails;
}

sub add_domains {
    my $self = shift;
    $self->add_valid_domains(@_);
}

sub add_valid_domains {
    my $class = shift;
    push @valid_domains , @_;
}

sub add_invalid_domains {

}

sub get_random_valid_domain {
    return $valid_domains[ 
        int( rand( scalar(@valid_domains) - 1 ) )
    ];
}

sub g_valid_identity {
    my $self = shift;
    my %args = @_;
    $args{seperator} ||= '_';
    my @random_words = rand_words( size => 3 );
    return join( $args{seperator} , @random_words );
}

sub g_invalid_identity {
    my ($self, %args ) = @_;

}



1; # End of Email::Sample