develooper Front page | perl.perl5.porters | Postings from March 2003

Data::Dumper ideas -

From:
jonathan stiles
Date:
March 21, 2003 04:25
Subject:
Data::Dumper ideas -
Message ID:
20030321005045.1210.qmail@web13303.mail.yahoo.com
hello all, 

I was wondering how easy it would be to implement the
following extensions to Data::Dumper, function Dumper:


1) contains: a function that would serve as a boolean 
             that tells whether or not a given data 
             structure contains a given string, either

             in the keys or values: 

             print STDERR Dumper($structure) if 
                     (contains($structure, 
                     sub { $_[0] =~ m"pattern"; }); 

             or perhaps:

             print STDERR Dumper($structure) 
                     if (contains($structure, 
                     {   pattern => 
                           sub {$_[0]=~m"pattern");}, 
                         check_keys => 1, 
                         check_values => 0 
                       }
                     ); 

             to check only the keys of the structure.

 2) filter out a data structure given a certain 
    criteria, ie: 

    my $dump = new Data::Dumper($structure); 
    my $newstruct = 
           $dump->filter(sub { $_[0] =~ m"pattern" });

    to say, make a data structure that only consists
of
    elements with the structure 'pattern' in it.

The more I use Data::Dumper, the more I find the
output from it overwhelming and need to filter it
based on some criteria. Are the above functions there,
or perhaps in another module, or would I need to
implement them myself?

jon 


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About