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

Data::Dumper ideas -

jonathan stiles
March 21, 2003 04:25
Data::Dumper ideas -
Message ID:
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 
                     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
    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?


Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About