NAME
Acrux::RefUtil - Pure Perl Utility functions for checking references and data
SYNOPSIS
use Acrux::RefUtil qw/ :all /;
DESCRIPTION
Pure Perl Utility functions for checking references and data
AS
The 'as' functions are introduced by the :as import tag, which check the type of passed argument and returns it as required type
- as_array_ref
 - 
This method returns the argument as a array reference
my $arr = as_array_ref( "foo" ); # ['foo'] my $arr = as_array_ref( "foo", "bar" ); # ['foo', 'bar'] my $arr = as_array_ref( ["foo", "bar"] ); # ['foo', 'bar'] my $arr = as_array_ref(); # [] my $arr = as_array_ref(undef); # [] my $arr = as_array_ref([undef]); # [undef] - as_array, as_list
 - 
This method returns argument as array-reference (see "as_array_ref") or regular array (list) in list context
my $arr = as_array( "foo", "bar" ); # ['foo', 'bar'] my @arr = as_array( "foo", "bar" ); # ('foo', 'bar') - as_first, as_first_val
 - 
This method returns the first scalar value from argument(s)
my $foo = as_first( [qw/foo bar baz/] ); my $foo = as_first( qw/foo bar baz/ ); - as_hash_ref
 - 
This method returns the argument as a hash reference
my $hash = as_hash_ref( {foo => 'one'} ); {foo => 'one'} my $hash = as_hash_ref( foo => 'one', bar => 2 ); # {foo => 'one', bar => 2 } my $hash = as_hash_ref(); # {} my $hash = as_hash_ref(undef); # {} - as_hash
 - 
This method returns argument as hash-reference (see "as_hash_ref") or regular hash in list context
my $hash = as_hash( "foo", "bar" ); # {'foo' => 'bar'} my %hash = as_hash( "foo", "bar" ); # ('foo', 'bar') - as_last, as_last_val, as_latest
 - 
This method returns the last scalar value from argument(s)
my $baz = as_last( [qw/foo bar baz/] ); my $baz = as_last( qw/foo bar baz/ ); 
CHECK
Check functions are introduced by the :check import tag, which check the argument type and return a bool
- is_ref
 - 
Checks for a any reference
 - is_scalar_ref
 - 
Checks for a SCALAR reference
 - is_array_ref
 - 
Checks for an ARRAY reference
 - is_hash_ref
 - 
Checks for a HASH reference
 - is_code_ref
 - 
Checks for a CODE reference
 - is_glob_ref
 - 
Checks for a GLOB reference
 - is_regexp_ref, is_regex_ref, is_rx
 - 
Checks for a regular expression reference generated by the
qr//operator - is_value
 - 
Checks whether value is a primitive value, i.e. a defined, non-ref, and non-type-glob value
 - is_string
 - 
Checks whether value is a string with non-zero-length contents, equivalent to is_value($value) && length($value) > 0
 - is_number
 - 
Checks whether value is a number
 - is_integer, is_int8, is_int16, is_int32, is_int64
 - 
Checks whether value is an integer
 - is_undef
 - 
Checks for a undef value
 
VOID
Void functions are introduced by the :void import tag, which check the argument type in void value and return a bool
- 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
 - 
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
 
FLAG
- is_false_flag
 - 
print "Disabled" if is_false_flag("off");If specified argument value is set to false then will be normalised to 1.
The following values will be considered as false:
no, off, 0, false, disableThis effect is case-insensitive, i.e. both "No" or "no" will result in 1.
 - is_true_flag
 - 
print "Enabled" if is_true_flag("on");If specified argument value is set to true then will be normalised to 1.
The following values will be considered as true:
yes, on, 1, true, enableThis effect is case-insensitive, i.e. both "Yes" or "yes" will result in 1.
 
HISTORY
See Changes file
TO DO
See TODO file
SEE ALSO
Data::Util::PurePerl, Params::Classify, Ref::Util, CTK::TFVals, CTK::ConfGenUtil
AUTHOR
Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>
COPYRIGHT
Copyright (C) 1998-2024 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/