NAME

CTK::TFVals - True & False values conversions

VERSION

Version 1.03

SYNOPSIS

use CTK::TFVals;

# Undef conversions
uv2zero( $value ); # Returns 0 if value is undef
uv2null( $value ); # Returns "" if value is undef (null/empty/void)
                   # Aliases:  uv2empty, uv2void

# False conversions
fv2undef( $value ); # Returns undef if value is false
fv2zero( $value ); # Returns 0 if value is false
fv2null( $value ); # Returns "" if value is false (null/empty/void)
                   # Aliases:  fv2empty, fv2void

# True conversions
tv2num( $value ); # Returns 0 unless value ~ ([+-])?\d+
                  # Aliases: tv2number
                  # Check-function: is_num
tv2flt( $value ); # Returns 0 unless value ~ ([+-])?\d+\.?\d*
                  # Aliases: tv2float
                  # Check-function: is_flt
tv2int( $value ); # Returns 0 unless value ~ \d{1,11}
                  # Returns 0 unless value >= 0 && < 99999999999
                  # Check-function: is_int
tv2int8( $value ); # Returns 0 unless value >= 0 && < 255
                   # Check-function: is_int8
tv2int16( $value ); # Returns 0 unless value >= 0 && < 65535
                    # Check-function: is_int16
tv2int32( $value ); # Returns 0 unless value >= 0 && < 4294967295
                    # Check-function: is_int32
tv2int64( $value ); # Returns 0 unless value >= 0 && < 2**64
                    # Check-function: is_int64
tv2intx( $value, $x ); # Returns 0 unless value >= 0 && < 2**$x
                    # Check-function: is_intx

DESCRIPTION

True & False values conversions

FUNCTIONS

uv2zero

This function returns the 0 value if argument is undef.

uv2zero( $value );
uv2null

This function returns the "" value if argument is undef.

uv2null( $value );
uv2empty

See "uv2null"

uv2void

See "uv2null"

fv2undef

This function returns the undev value if argument is false.

fv2undef( $value );
fv2zero

This function returns the 0 value if argument is false.

fv2zero( $value );
fv2null

This function returns the "" value if argument is false.

fv2null( $value );
fv2empty

See "fv2null"

fv2void

See "fv2null"

tv2num

This function returns the 0 value unless argument ~ ([+-])?\d+

tv2num( $value );
tv2number

See "tv2num"

tv2flt

This function returns the 0 value unless argument ~ ([+-])?\d+\.?\d*

tv2flt( $value );
tv2float

See "tv2flt"

tv2int

This function returns the 0 value unless argument ~ \d{1,11} and argument value > 0 && < 99999999999

tv2int( $value );
tv2int8

This function returns the 0 value unless argument value >= 0 && < 255

tv2int8( $value );
tv2int16

This function returns the 0 value unless argument value >= 0 && < 65535

tv2int16( $value );
tv2int32

This function returns the 0 value unless argument value >= 0 && < 4294967295

tv2int32( $value );
tv2int64

This function returns the 0 value unless argument value >= 0 && < 2**64

tv2int64( $value );
tv2intx

This function returns the 0 value unless argument value >= 0 && < 2**$x

tv2int64( $value, $x );
is_num

This function returns true if argument ~ ([+-])?\d+

is_num( $value );
is_flt

This function returns true if argument ~ ([+-])?\d+\.?\d*

is_flt( $value );
is_int

This function returns true if argument ~ \d{1,20} and argument value >= 0 && < 99999999999999999999

is_int( $value );
is_int8

This function returns true if argument value >= 0 && < 255

is_int8( $value );
is_int16

This function returns true if argument value >= 0 && < 65535

is_int16( $value );
is_int32

This function returns true if argument value >= 0 && < 4294967295

is_int32( $value );
is_int64

This function returns true if argument value >= 0 && < 2**64

is_int64( $value );
is_intx

This function returns true if argument value >= 0 && < 2**$x

is_intx( $value, $x );
is_void
print "Void" if is_void({});

Returns true if the structure contains useful data. Useful data - this data is different from the value undef

isnt_void, is_not_void
print "NOT Void" if isnt_void({foo=>undef});

Returns true if the structure does not contain any nested useful data. Useful data - this data is different from the value undef

TAGS

:ALL

Export all subroutines:

"uv2zero", "uv2null", "uv2empty", "uv2void", "fv2undef", "fv2zero", "fv2null", "fv2empty", "fv2void", "tv2num", "tv2number", "is_num", "tv2flt", "tv2float", "is_flt", "tv2int", "is_int", "tv2int8", "is_int8", "tv2int16", "is_int16", "tv2int32", "is_int32", "tv2int64", "is_int64", "tv2intx", "is_intx", "is_void", "isnt_void", "is_not_void"

:DEFAULT

"uv2zero", "uv2null", "uv2empty", "uv2void", "fv2undef", "fv2zero", "fv2null", "fv2empty", "fv2void", "tv2num", "tv2int", "tv2flt"

:UNDEF

"uv2zero", "uv2null", "uv2empty", "uv2void"

:FALSE

"fv2undef", "fv2zero", "fv2null", "fv2empty", "fv2void"

:TRUE

"tv2num", "tv2number", "tv2flt", "tv2float", "tv2int", "tv2int8", "tv2int16", "tv2int32", "tv2int64", "tv2intx"

:CHCK, :CHECK

"is_num", "is_flt", "is_int", "is_int8", "is_int16", "is_int32", "is_int64", "is_intx", "is_void", "isnt_void", "is_not_void"

HISTORY

See Changes file

TO DO

See TODO file

BUGS

* none noted

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/