Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

A more elegant way to filter a nested hash?

by jimpudar (Pilgrim)
on May 31, 2018 at 00:19 UTC ( [id://1215517]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $source = {
        f1 => 'garbage',
    ...
        f10 => [ 'important', 'data' ],
        f11 => [ 'more', 'garbage' ]
    };
    
  2. or download this
    my $filter = {
        f3 => 1,
    ...
        },
        f10 => 1
    };
    
  3. or download this
    my $output = {
        f3 => 'important data',
    ...
        },
        f10 => [ 'important', 'data' ],
    };
    
  4. or download this
    sub hash_filter {
      my $source = shift;
    ...
    
      return \%output;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1215517]
Approved by Athanasius
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-19 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found