Data::RandomPerson - Create random people
This document refers to version 0.4 of Data::RandomPerson, released Sept 13th, 2005
use Data::RandomPerson; my $r = Data::RandomPerson->new(); my $p = $r->create();
Returns an object that can be used to create random people and return the data in a hash. The data is a hash reference with the following keys:
This is either 'm' or 'f'
The number of years old of the person
The date of birth of the person based upon how old they are in the current year. The month and day portion are selected randomly.
The person's first name based on their gender. The names are picked from Data::RandomPerson::Name::{Male,Female} unless other classes are supplied to the new method.
The person's last name. The names are picked from Data::RandomPerson::Name::Last unless another class is supplied to the new method.
The person's title based on their age and gender.
Create the Data::RandomPerson object. By default Data::RandomPerson::Names::{Male,Female,Last} are used to supply the male, female and last names. To pass in other classes to use you just put male => 'MyNames::Male' as arguments to the method. The three keys are 'male', 'female', and 'last'.
Returns 'm' or 'f' with equal probability. This can be overridden to adjust the ratio on males to females in your target population.
Returns an age between 1 and 100. This can be overridden to return values in the range required of your target population.
Calculates the date of birth from the age in the format YYYY-MM-DD. The YYYY value is the current year less the age, MM and DD and random, valid, values. This method should not need to be overridden unless the date format is not what you require.
Return a suitable title based on the age and gender of the person. The ratios used here are completely made up and until I can get hold of some hard data, like a copy of the electoral roll, it can only be a best guess.
Returns a last name from the class loaded by the init() method. You should not need to override this method.
Returns a first name of the correct gender from the class loaded by the init() method. You should not need to override this method.
Returns a newly created person as a hash reference with the following keys: gender, age, dob, firstname, lastname and title. A new person is returned for each call of the method although there is no guarantee of uniqueness.
Perl 5
There are only three arguments that can be optionally passed to new. These are 'male', 'female' and 'last' and they should be the classes that will be used to get the male, female and last names.
A class given to load instead of the default class could not be loaded. Hopefully a sensible reason will be given.
None so far
None
A simple class for selecting elements from a weighted list
A list of female first names from census data
A list of last names from census data
A list of male first names from census data
Names from Chris Pound's language machine page at http://www.ruf.rice.edu/~pound/#scripts
Peter Hickman (peterhi@ntlworld.com)
Copyright (c) 2005, Peter Hickman. All rights reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
To install Data::RandomPerson, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::RandomPerson
CPAN shell
perl -MCPAN -e shell install Data::RandomPerson
For more information on module installation, please visit the detailed CPAN module installation guide.