Data::Delete - Delete keys with undefined or empty string values in a deep data structure
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" } ] }
A module for when you want to remove HashRef keys when the value is undefined or an empty string.
Turn on/off debugging
Choose to remove empty string hash values
Signature: (HashRef|ArrayRef) Returns: The data structure with undefined hash values, and optionally, empty string hash values removed
Mateu X Hunter hunter@missoula.org
hunter@missoula.org
Copyright 2015, Mateu X Hunter
You may distribute this code under the same terms as Perl itself.
To install Data::Skeleton, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Skeleton
CPAN shell
perl -MCPAN -e shell install Data::Skeleton
For more information on module installation, please visit the detailed CPAN module installation guide.