Acrux
view release on metacpan or search on metacpan
lib/Acrux/RefUtil.pm view on Meta::CPAN
=item 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); # {}
=item as_hash
This method returns argument as hash-reference (see L</"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')
=item 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/ );
=back
=head2 CHECK
Check functions are introduced by the C<:check> import tag, which check
the argument type and return a bool
=over 4
=item is_ref
Checks for a any reference
=item is_scalar_ref
Checks for a SCALAR reference
=item is_array_ref
Checks for an ARRAY reference
=item is_hash_ref
Checks for a HASH reference
=item is_code_ref
Checks for a CODE reference
=item is_glob_ref
Checks for a GLOB reference
=item is_regexp_ref, is_regex_ref, is_rx
Checks for a regular expression reference generated by the C<qr//> operator
=item is_value
Checks whether I<value> is a primitive value, i.e. a defined, non-ref, and
non-type-glob value
=item is_string
Checks whether I<value> is a string with non-zero-length contents,
equivalent to is_value($value) && length($value) > 0
=item is_number
Checks whether I<value> is a number
=item is_integer, is_int8, is_int16, is_int32, is_int64
Checks whether I<value> is an integer
=item is_undef
Checks for a undef value
=back
=head2 VOID
Void functions are introduced by the C<:void> import tag, which check
the argument type in void value and return a bool
=over 4
=item 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
=item 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
=back
=head2 FLAG
=over 4
=item 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:
( run in 0.683 second using v1.01-cache-2.11-cpan-df04353d9ac )