NAME

Weather::GHCN::Common - common functions for GHCN scripts and modules

VERSION

version v0.0.007

SYNOPSIS

use Weather::GHCN::Common qw(:all);

DESCRIPTION

The Weather::GHCN::Common module provides functions that are used in more than one GHCN module, or that may be useful in application scripts; e.g. rng_valid() to validate number ranges that might be provided to a script using command line arguments.

The module is primarily for use by modules Weather::GHCN::Fetch, Weather::GHCN::Options, Weather::GHCN::Station, and Weather::GHCN::StationTable.

FUNCTIONS

commify($number)

Insert commas into a number so that digits are grouped in threes; e.g. 12345 becomes 12,345.

The argument can be a number or a string of digits, with or without a decimal. Digits after a decimal are unaffected.

rng_new(@args)

Wrapper for Set::IntSpan::Fast->new(), it provides a shorter name as well as:

- allowing an undef $range to create an empty set
- croaking if new() fails for any reason

The arguments to rng_new can consist of a range string (e.g. '1-5,12') or a perl list of numbers (e.g. 1,7,12,20..25) or a mix of both.

rng_valid($range)

Returns true if the range string is valid for Set::IntSpan::Fast. Valid ranges consist of numbers, a pair of numbers delimited by dash (e.g 15-75), or a mix of those delimited by commas (e.g. '5-9,12,25-30').

rng_within($range, $domain)

Returns true if the range string is lies within the domain range. For example rng_within('3-5', '1-12') return true, whereas rng_within('1800,1950', '1900-2100') returns false because 1800 is not within the domain of 1900 to 2100.

tsv($list_or_list_of_lists)

Takes a perl list and returns an equivalent tab-separated string. Alternatively, takes a list of lists and returns a newline-separated string of tab-separated values.

iso_date_time(@now)

Takes the first 6 elements from a perl localtime array and formats them into an ISO date string YYYY-MM-DD HH:MM:SS.

AUTHOR

Gary Puckering (jgpuckering@rogers.com)

LICENSE AND COPYRIGHT

Copyright 2022, Gary Puckering