NAME
Data::Delete - Delete keys with undefined or empty string values in a deep data structure
SYNOPSIS
use Data::Delete;
my $dd = Data::Delete->new;
my $deep_data_structure = {
id => 4,
last_modified => undef,
sections => [
{
content => 'h1. Ice Cream',
class => 'textile'
},
{
content => '# Pie',
class => ''
},
],
};
use Data::Dumper;
print Dumper $dd->delete($deep_data_structure);
# results in:
{
id => "4",
sections => [
{
content => 'h1. Ice Cream',
class => 'textile'
},
{
content => "# Pie"
}
]
}
DESCRIPTION
A module for when you want to remove HashRef keys when the value is undefined or an empty string.
debug_delete
Turn on/off debugging
will_delete_empty_string
Choose to remove empty string hash values - default true
will_delete_empty_ref
Choose to remove empty array, hash and scalar ref values - default false
METHODS
delete
Signature: (HashRef|ArrayRef)
Returns: The data structure with undefined hash values, and optionally,
empty string hash values removed
AUTHORS
Mateu X Hunter hunter@406mt.org
COPYRIGHT
Copyright 2024, Mateu X Hunter
LICENSE
You may distribute this code under the same terms as Perl itself.