NAME App::PhoneNumberUtils - Utilities related to phone numbers VERSION This document describes version 0.006 of App::PhoneNumberUtils (from Perl distribution App-PhoneNumberUtils), released on 2022-09-13. DESCRIPTION This distributions provides the following command-line utilities: * format-phone-number * format-phone-number-idn * normalize-phone-number * normalize-phone-number-idn * phone-number-info * phone-number-is-valid FUNCTIONS normalize_phone_number Usage: normalize_phone_number(%args) -> [$status_code, $reason, $payload, \%result_meta] Normalize phone number. Examples: * Example #1: normalize_phone_number(phnums => ["+442087712924"]); # -> [200, "OK", "+44 20 8771 2924", {}] * Example #2: normalize_phone_number(phnums => ["+6281812345678"]); # -> [200, "OK", "+62 818 1234 5678", {}] This utility uses Number::Phone to format the phone number, which supports country-specific formatting rules. The phone number must be an international phone number (e.g. +6281812345678 instead of 081812345678). But if you specify the "default_country_code" option, you can supply a local phone number (e.g. 081812345678) and it will be formatted as international phone number. This utility can accept multiple numbers from command-line arguments or STDIN. This function is not exported. Arguments ('*' denotes required arguments): * default_country_code => *country::code::alpha2* * phnums => *array[str]* * strip_whitespace => *bool* Returns an enveloped result (an array). First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata. Return value: (any) normalize_phone_number_idn Usage: normalize_phone_number_idn(%args) -> [$status_code, $reason, $payload, \%result_meta] Normalize phone number (for Indonesian number). Examples: * Example #1: normalize_phone_number_idn(phnums => ["+6281812345678"]); # -> [200, "OK", "+62 818 1234 5678", {}] * Example #2: normalize_phone_number_idn(phnums => [6281812345678]); # -> [200, "OK", "+62 818 1234 5678", {}] * Example #3: normalize_phone_number_idn(phnums => ["081812345678"]); # -> [200, "OK", "+62 818 1234 5678", {}] This is a shortcut for: % normalize-phone-number --default-country-code id This function is not exported. Arguments ('*' denotes required arguments): * phnums => *array[str]* * strip_whitespace => *bool* Returns an enveloped result (an array). First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata. Return value: (any) phone_number_info Usage: phone_number_info(%args) -> [$status_code, $reason, $payload, \%result_meta] Show information about a phone number. Examples: * Example #1: phone_number_info(phnum => "+442087712924"); Result: [ 200, "OK", { areacode => 20, areaname => "London", country_code => 44, format => "+44 20 8771 2924", format_for_country => "+44 20 8771 2924", is_adult => 0, is_allocated => 1, is_corporate => 0, is_drama => 0, is_fixed_line => undef, is_geographic => 1, is_government => undef, is_in_use => undef, is_international => undef, is_ipphone => 0, is_isdn => undef, is_mobile => 0, is_network_service => 0, is_pager => 0, is_personal => 0, is_valid => 1, location => [51.38309, -0.336079], operator => "BT", operator_ported => undef, regulator => "OFCOM, http://www.ofcom.org.uk/", subscriber => 87712924, }, {}, ] * Example #2: phone_number_info(phnum => "+6281812345678"); Result: [ 200, "OK", { areacode => undef, areaname => undef, country_code => 62, format => "+62 818 1234 5678", format_for_country => "+62 818-1234-5678", is_adult => undef, is_allocated => undef, is_corporate => undef, is_drama => undef, is_fixed_line => 0, is_geographic => 0, is_government => undef, is_in_use => undef, is_international => undef, is_ipphone => undef, is_isdn => undef, is_mobile => 1, is_network_service => undef, is_pager => undef, is_personal => undef, is_valid => 1, location => undef, operator => undef, operator_ported => undef, regulator => undef, subscriber => undef, }, {}, ] This utility uses Number::Phone to get information for a phone number. For certain countries, the information provided can be pretty detailed including coordinate, whether the number is an adult line, and the operator name. For other countries, the information provided is more basic including whether a number is a mobile number. This function is not exported. Arguments ('*' denotes required arguments): * phnum* => *str* Returns an enveloped result (an array). First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata. Return value: (any) phone_number_is_valid Usage: phone_number_is_valid(%args) -> [$status_code, $reason, $payload, \%result_meta] Check whether phone number is valid. Examples: * Example #1: phone_number_is_valid(phnum => "+442087712924"); # -> [200, "OK", 1, { "cmdline.exit_code" => 0 }] * Example #2: phone_number_is_valid(phnum => "+4420877129240"); # -> [200, "OK", 0, { "cmdline.exit_code" => 1 }] * Example #3: phone_number_is_valid(phnum => "+6281812345678"); # -> [200, "OK", 1, { "cmdline.exit_code" => 0 }] * Example #4: phone_number_is_valid(phnum => "+6281812345"); # -> [200, "OK", 0, { "cmdline.exit_code" => 1 }] This utility uses Number::Phone to determine whether a phone number is valid. This function is not exported. Arguments ('*' denotes required arguments): * phnum* => *str* * quiet => *true* Returns an enveloped result (an array). First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata. Return value: (any) HOMEPAGE Please visit the project's homepage at . SOURCE Source repository is at . SEE ALSO Number::Phone AUTHOR perlancar CONTRIBUTING To contribute, you can send patches by email/via RT, or send pull requests on GitHub. Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via: % prove -l If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me. COPYRIGHT AND LICENSE This software is copyright (c) 2022, 2021, 2018 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. BUGS Please report any bugs or feature requests on the bugtracker website When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.