NAME
Faker - Fake Data Generator
ABSTRACT
Extensible Fake Data Generator
VERSION
1.19
SYNOPSIS
DESCRIPTION
This distribution provides a library of fake data generators and a framework for extending the library via plugins.
ATTRIBUTES
This package has the following attributes:
caches
caches(HashRef
$data
) (Object)
The caches attribute holds the cached values returned from "cache".
Since 1.10
locales
locales(ArrayRef
$data
) (Object)
The locales attribute holds the locales used to find and generate localized data.
Since 1.10
- locales example 2
-
# given: synopsis
package
main;
my
$locales
=
$faker
->locales([]);
# bless({value => []}, 'Venus::Array')
INTEGRATES
This package integrates behaviors from:
METHODS
This package provides the following methods:
address_city_name
address_city_name(HashRef
$data
) (Str)
The address_city_name method returns a random address city name.
Since 1.10
address_city_prefix
address_city_prefix(HashRef
$data
) (Str)
The address_city_prefix method returns a random address city prefix.
Since 1.10
address_city_suffix
address_city_suffix(HashRef
$data
) (Str)
ok $address_city_suffix method returns a random address city suffix.
Since 1.10
address_country_name
address_country_name(HashRef
$data
) (Str)
The address_country_name method returns a random address country name.
Since 1.10
address_latitude
address_latitude(HashRef
$data
) (Str)
The address_latitude method returns a random address latitude.
Since 1.10
address_line1
address_line1(HashRef
$data
) (Str)
The address_line1 method returns a random address line1.
Since 1.10
address_line2
address_line2(HashRef
$data
) (Str)
The address_line2 method returns a random address line2.
Since 1.10
address_lines
address_lines(HashRef
$data
) (Str)
The address_lines method returns a random address lines.
Since 1.10
- address_lines example 1
-
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
# my $address_lines = $faker->address_lines;
# "4 Koelpin Plaza Unit 694\nWest Viviane, IA 37022"
# $address_lines = $faker->address_lines;
# "90558 Greenholt Orchard\nApt. 250\nPfannerstillberg, New Mexico 52836"
# $address_lines = $faker->address_lines;
# "68768 Weissnat Point\nRitchieburgh, New Mexico 53892"
address_longitude
address_longitude(HashRef
$data
) (Str)
The address_longitude method returns a random address longitude.
Since 1.10
address_number
address_number(HashRef
$data
) (Str)
The address_number method returns a random address number.
Since 1.10
address_postal_code
address_postal_code(HashRef
$data
) (Str)
The address_postal_code method returns a random address postal code.
Since 1.10
address_region_name
address_region_name(HashRef
$data
) (Str)
The address_region_name method returns a random address region name.
Since 1.10
address_state_abbr
address_state_abbr(HashRef
$data
) (Str)
The address_state_abbr method returns a random address state abbr.
Since 1.10
address_state_name
address_state_name(HashRef
$data
) (Str)
The address_state_name method returns a random address state name.
Since 1.10
address_street_address
address_street_address(HashRef
$data
) (Str)
The address_street_address method returns a random address street address.
Since 1.10
- address_street_address example 1
-
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
# my $address_street_address = $faker->address_street_address;
# "4084 Mayer Brook Suite 94"
# $address_street_address = $faker->address_street_address;
# "9908 Mustafa Harbor Suite 828"
# $address_street_address = $faker->address_street_address;
# "958 Greenholt Orchard"
address_street_name
address_street_name(HashRef
$data
) (Str)
The address_street_name method returns a random address street name.
Since 1.10
address_street_suffix
address_street_suffix(HashRef
$data
) (Str)
The address_street_suffix method returns a random address street suffix.
Since 1.10
cache
cache(Str
$method
, Any
@args
) (Str)
The cache method dispatches to the method specified, caches the method name and return value, and returns the value. Subsequent calls will return the cached value.
Since 1.10
color_hex_code
color_hex_code(HashRef
$data
) (Str)
The color_hex_code method returns a random color hex code.
Since 1.10
color_name
color_name(HashRef
$data
) (Str)
The color_name method returns a random color name.
Since 1.10
color_rgb_colorset
color_rgb_colorset(HashRef
$data
) (Str)
The color_rgb_colorset method returns a random color rgb colorset.
Since 1.10
color_rgb_colorset_css
color_rgb_colorset_css(HashRef
$data
) (Str)
The color_rgb_colorset_css method returns a random color rgb colorset css.
Since 1.10
color_safe_hex_code
color_safe_hex_code(HashRef
$data
) (Str)
The color_safe_hex_code method returns a random color safe hex code.
Since 1.10
color_safe_name
color_safe_name(HashRef
$data
) (Str)
The color_safe_name method returns a random color safe name.
Since 1.10
company_description
company_description(HashRef
$data
) (Str)
The company_description method returns a random company description.
Since 1.10
- company_description example 1
-
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
# my $company_description = $faker->company_description;
# "Excels at full-range synchronised implementations"
# $company_description = $faker->company_description;
# "Provides logistical ameliorated methodologies"
# $company_description = $faker->company_description;
# "Offering hybrid future-proofed applications"
company_name
company_name(HashRef
$data
) (Str)
The company_name method returns a random company name.
Since 1.10
company_name_suffix
company_name_suffix(HashRef
$data
) (Str)
The company_name_suffix method returns a random company name suffix.
Since 1.10
company_tagline
company_tagline(HashRef
$data
) (Str)
The company_tagline method returns a random company tagline.
Since 1.10
internet_domain_name
internet_domain_name(HashRef
$data
) (Str)
The internet_domain_name method returns a random internet domain name.
Since 1.10
internet_domain_tld
internet_domain_tld(HashRef
$data
) (Str)
The internet_domain_tld method returns a random internet domain tld.
Since 1.10
internet_domain_word
internet_domain_word(HashRef
$data
) (Str)
The internet_domain_word method returns a random internet domain word.
Since 1.10
internet_email_address
internet_email_address(HashRef
$data
) (Str)
The internet_email_address method returns a random internet email address.
Since 1.10
- internet_email_address example 1
-
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
# my $internet_email_address = $faker->internet_email_address;
# "russel54\@mayer-balistreri-and-miller.com"
# $internet_email_address = $faker->internet_email_address;
# "viviane82\@rempel-entertainment.com"
# $internet_email_address = $faker->internet_email_address;
# "yborer\@outlook.com"
internet_email_domain
internet_email_domain(HashRef
$data
) (Str)
The internet_email_domain method returns a random internet email domain.
Since 1.10
internet_ip_address
internet_ip_address(HashRef
$data
) (Str)
The internet_ip_address method returns a random internet ip address.
Since 1.10
internet_ip_address_v4
internet_ip_address_v4(HashRef
$data
) (Str)
The internet_ip_address_v4 method returns a random internet ip address v4.
Since 1.10
internet_ip_address_v6
internet_ip_address_v6(HashRef
$data
) (Str)
The internet_ip_address_v6 method returns a random internet ip address v6.
Since 1.10
- internet_ip_address_v6 example 1
-
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
# my $internet_ip_address_v6 = $faker->internet_ip_address_v6;
# "57bb:1c70:6c1e:14c3:db3f:7fb1:7a93:b0d9"
# $internet_ip_address_v6 = $faker->internet_ip_address_v6;
# "7680:93e0:88b2:06a0:c512:99e4:e8a9:7d48"
# $internet_ip_address_v6 = $faker->internet_ip_address_v6;
# "7f27:7009:5984:ec03:0f75:dc22:f8d4:d951"
internet_url
internet_url(HashRef
$data
) (Str)
The internet_url method returns a random internet url.
Since 1.10
jargon_adjective
jargon_adjective(HashRef
$data
) (Str)
The jargon_adjective method returns a random jargon adjective.
Since 1.10
jargon_adverb
jargon_adverb(HashRef
$data
) (Str)
The jargon_adverb method returns a random jargon adverb.
Since 1.10
jargon_noun
jargon_noun(HashRef
$data
) (Str)
The jargon_noun method returns a random jargon noun.
Since 1.10
jargon_term_prefix
jargon_term_prefix(HashRef
$data
) (Str)
The jargon_term_prefix method returns a random jargon term prefix.
Since 1.10
jargon_term_suffix
jargon_term_suffix(HashRef
$data
) (Str)
The jargon_term_suffix method returns a random jargon term suffix.
Since 1.10
jargon_verb
jargon_verb(HashRef
$data
) (Str)
The jargon_verb method returns a random jargon verb.
Since 1.10
lorem_paragraph
lorem_paragraph(HashRef
$data
) (Str)
The lorem_paragraph method returns a random lorem paragraph.
Since 1.10
- lorem_paragraph example 1
-
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
# my $lorem_paragraph = $faker->lorem_paragraph;
# "deleniti fugiat in accusantium animi corrupti dolores. eos ..."
# $lorem_paragraph = $faker->lorem_paragraph;
# "ducimus placeat autem ut sit adipisci asperiores quae ipsum..."
# $lorem_paragraph = $faker->lorem_paragraph;
# "dignissimos est magni quia aut et hic eos architecto repudi..."
lorem_paragraphs
lorem_paragraphs(HashRef
$data
) (Str)
The lorem_paragraphs method returns a random lorem paragraphs.
Since 1.10
- lorem_paragraphs example 1
-
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
# my $lorem_paragraphs = $faker->lorem_paragraphs;
# "eligendi laudantium provident assumenda voluptates sed iu..."
# $lorem_paragraphs = $faker->lorem_paragraphs;
# "accusantium ex pariatur perferendis voluptate iusto iure fu..."
# $lorem_paragraphs = $faker->lorem_paragraphs;
# "sit ut molestiae consequatur error tempora inventore est so..."
lorem_sentence
lorem_sentence(HashRef
$data
) (Str)
The lorem_sentence method returns a random lorem sentence.
Since 1.10
- lorem_sentence example 1
-
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
# my $lorem_sentence = $faker->lorem_sentence;
# "vitae et eligendi laudantium provident assumenda voluptates..."
# $lorem_sentence = $faker->lorem_sentence;
# "aspernatur qui ad error numquam illum sunt cupiditate recus..."
# $lorem_sentence = $faker->lorem_sentence;
# "incidunt ut ratione sequi non illum laborum dolorum et earu..."
lorem_sentences
lorem_sentences(HashRef
$data
) (Str)
The lorem_sentences method returns a random lorem sentences.
Since 1.10
- lorem_sentences example 1
-
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
# my $lorem_sentences = $faker->lorem_sentences;
# "vero deleniti fugiat in accusantium animi corrupti. et eos ..."
# $lorem_sentences = $faker->lorem_sentences;
# "enim accusantium aliquid id reprehenderit consequatur ducim..."
# $lorem_sentences = $faker->lorem_sentences;
# "reprehenderit ut autem cumque ea sint dolorem impedit et qu..."
lorem_word
lorem_word(HashRef
$data
) (Str)
The lorem_word method returns a random lorem word.
Since 1.10
lorem_words
lorem_words(HashRef
$data
) (Str)
The lorem_words method returns a random lorem words.
Since 1.10
new
new(Str
$data
| ArrayRef
$data
| HashRef
$data
) (Faker)
The new method returns a new instance of the class.
Since 1.10
payment_card_american_express
payment_card_american_express(HashRef
$data
) (Str)
The payment_card_american_express method returns a random payment card american express.
Since 1.10
- payment_card_american_express example 1
-
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
# my $payment_card_american_express = $faker->payment_card_american_express;
# 34140844684550
# $payment_card_american_express = $faker->payment_card_american_express;
# 37945443908982
# $payment_card_american_express = $faker->payment_card_american_express;
# 34370225828820
payment_card_discover
payment_card_discover(HashRef
$data
) (Str)
The payment_card_discover method returns a random payment card discover.
Since 1.10
payment_card_expiration
payment_card_expiration(HashRef
$data
) (Str)
The payment_card_expiration method returns a random payment card expiration.
Since 1.10
payment_card_mastercard
payment_card_mastercard(HashRef
$data
) (Str)
The payment_card_mastercard method returns a random payment card mastercard.
Since 1.10
payment_card_number
payment_card_number(HashRef
$data
) (Str)
The payment_card_number method returns a random payment card number.
Since 1.10
payment_card_visa
payment_card_visa(HashRef
$data
) (Str)
The payment_card_visa method returns a random payment card visa.
Since 1.10
payment_vendor
payment_vendor(HashRef
$data
) (Str)
The payment_vendor method returns a random payment vendor.
Since 1.10
person_first_name
person_first_name(HashRef
$data
) (Str)
The person_first_name method returns a random person first name.
Since 1.10
person_formal_name
person_formal_name(HashRef
$data
) (Str)
The person_formal_name method returns a random person formal name.
Since 1.10
person_gender
person_gender(HashRef
$data
) (Str)
The person_gender method returns a random person gender.
Since 1.10
person_last_name
person_last_name(HashRef
$data
) (Str)
The person_last_name method returns a random person last name.
Since 1.10
person_name
person_name(HashRef
$data
) (Str)
The person_name method returns a random person name.
Since 1.10
person_name_prefix
person_name_prefix(HashRef
$data
) (Str)
The person_name_prefix method returns a random person name prefix.
Since 1.10
person_name_suffix
person_name_suffix(HashRef
$data
) (Str)
The person_name_suffix method returns a random person name suffix.
Since 1.10
software_author
software_author(HashRef
$data
) (Str)
The software_author method returns a random software author.
Since 1.10
software_name
software_name(HashRef
$data
) (Str)
The software_name method returns a random software name.
Since 1.10
software_semver
software_semver(HashRef
$data
) (Str)
The software_semver method returns a random software semver.
Since 1.10
software_version
software_version(HashRef
$data
) (Str)
The software_version method returns a random software version.
Since 1.10
telephone_number
telephone_number(HashRef
$data
) (Str)
The telephone_number method returns a random telephone number.
Since 1.10
user_login
user_login(HashRef
$data
) (Str)
The user_login method returns a random user login.
Since 1.10
user_password
user_password(HashRef
$data
) (Str)
The user_password method returns a random user password.
Since 1.10
FEATURES
This package provides the following features:
- plugins-feature
-
This package loads and dispatches calls to plugins (the fake data generators) which allow for extending the library in environment-specific ways.
example 1
package
Faker::Plugin::HttpContentType;
sub
execute {
'video/mpeg'
}
package
main;
use
Faker;
my
$faker
= Faker->new;
my
$http_content_type
=
$faker
->http_content_type;
# "video/mpeg"
example 2
package
Faker::Plugin::HttpContentType;
sub
execute {
'video/mpeg'
}
package
main;
my
$plugin
= Faker::Plugin::HttpContentType->new;
my
$http_content_type
=
$plugin
->execute;
# "video/mpeg"
- locales-feature
-
This package can be configured to return localized fake data, typically organized under namespaces specific to the locale specified.
example 1
example 2
package
Faker::Plugin::Klingon::RandomPhrase;
sub
execute {
'nuqDaq ’oH puchpa’’e’'
}
package
main;
use
Faker;
my
$faker
= Faker->new(
'klingon'
);
my
$random_phrase
=
$faker
->random_phrase;
# "nuqDaq ’oH puchpa’’e’"
example 3
sub
execute {
'Hash yer dothrae chek asshekh?'
}
package
Faker::Plugin::Klingon::RandomPhrase;
sub
execute {
'nuqDaq ’oH puchpa’’e’'
}
package
main;
use
Faker;
my
$faker
= Faker->new([
'dothraki'
,
'klingon'
]);
my
$random_phrase
=
$faker
->random_phrase;
# "nuqDaq ’oH puchpa’’e’"
# $random_phrase = $faker->random_phrase;
# "Hash yer dothrae chek asshekh?"
# $random_phrase = $faker->random_phrase;
# "nuqDaq ’oH puchpa’’e’"
# $random_phrase = $faker->random_phrase;
# "nuqDaq ’oH puchpa’’e’"
- caching-feature
-
Often one generator's fake data is composed of the output from other generators. Caching can be used to make generators faster, and to make fake data more realistic.
example 1
package
main;
use
Faker;
my
$faker
= Faker->new(
'en-us'
);
my
$person_first_name
=
$faker
->person_first_name;
# "Jordi"
my
$person_last_name
=
$faker
->person_last_name;
# "Smitham"
my
$internet_email_address
=
$faker
->internet_email_address;
# "deshaun8768@hotmail.com"
$person_first_name
=
$faker
->cache(
'person_first_name'
);
# "Arlene"
$person_last_name
=
$faker
->cache(
'person_last_name'
);
# "Cassin"
$internet_email_address
=
$faker
->internet_email_address;
# "arlene6025@proton.me"
AUTHORS
Awncorp, awncorp@cpan.org
LICENSE
Copyright (C) 2000, Al Newkirk.
This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.